Subversion notes
From raju
filtering the log messages
Increase the context when doing svn diff
What files changed locally?
What changed in a version?
What files changed in a revision?
% svn diff --summarize -c r297
What changes were made in a revision?
% svn diff -c r297
To show the files changed in a revision as well as the commit message
% svn log --verbose -r316
What changed between versions?
What files changed between two revisions (a,b]?
% svn diff --summarize -r310:r314
What changes were made between two revisions (a,b]?
% svn diff -r310:r314
revert a commit
cd into the directory
% svn merge -c -317 . --- Reverse-merging r317 into '.': U src/HotCold.C
To revert a range of commits
% svn merge -r HIGHREV:LOWREV .
To revert multiple single commits
% svn merge -c -315,308 .
keyword substitution
tag | automatic headers, keyword expansion
For Perl files I use
#! /usr/bin/env perl #============================= # Last edited by: $Author$ # on: $Date$ # Revision: $Revision$ # url: $HeadURL$
% svn propset svn:keywords "Author Date Revision HeadURL" script.pl
The keywords will be expanded once the file is committed.
Ref:- http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.keywords.html
use vimdiff when doing svn diff
- Download https://github.com/c4rlo/Subversion-scripts/blob/master/svndiff_helper into ~/bin/svndiff_helper
- By default the script uses gvimdiff to show the differences. But this can be cumbersome when working over ssh. So, change it to use vimdiff. This is done by modifying
vim_rc = subprocess.call(['vim', '-dfgR', '--cmd', "au BufReadPost " + lf1 + " silent f " + sanitise(n1), '--cmd', "au BufReadPost " + lf2 + " silent f " + sanitise(n2), lf1, lf2])
to
vim_rc = subprocess.call(['vim', '-dfR', '--cmd', "au BufReadPost " + lf1 + " silent f " + sanitise(n1), '--cmd', "au BufReadPost " + lf2 + " silent f " + sanitise(n2), lf1, lf2])
- chmod +x ~/bin/svndiff_helper
- svn diff --diff-cmd ~/bin/svndiff_helper
undo an svn add
To undo an svn add file_name
svn rm --keep-local file_name
list all tracked files
To list all svn tracked files in a directory
svn list <dir>
Recursively, list all tracked files
svn list -R <dir>
Create a trunk directory in an existing subversion project
Sample script
$cat make_trunk.sh #! /usr/bin/env bash set -x # Create a trunk directory in # http://hostname:port/path/to/svn/repo/ and move all # the code below it into the trunk directory. REPO_URL="http://hostname:port/path/to/svn/repo/" svn mkdir $REPO_URL/trunk -m "Create a trunk directory" dirs=( "foo" "bar" "baz" "qux" "quux" ) for i in ${dirs[@]} do svn move $REPO_URL/$i $REPO_URL/trunk/$i -m "moving $i into trunk" done
After that, use http://hostname:port/path/to/svn/repo/trunk to check out and commit the code instead of http://hostname:port/path/to/svn/repo .
If you have a local version already checked out from the old URL, use the “svn switch” command to point to new new URL by doing something as follows.
- Make a backup of your local repo
cp –iR local_repo local_repo_bkup
- In the local repo, remove any uncommitted changes.
- Run
svn switch http://hostname:port/path/to/svn/repo/trunk --ignore-ancestry
If successful, the output should show something like
U . Updated to revision 127.
The version number you get might be different.
- Use svn info to confirm the new repo URL
$svn info | grep -i url URL: http://hostname:port/path/to/svn/repo/trunk Relative URL: ^/repo/trunk
- Copy the uncommitted changes from the backup repo to the current repo.
Ref:- https://stackoverflow.com/a/27242978/6305733
check the difference between local and remote versions
svn diff -rBASE:HEAD
Useful links
- http://commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art025 - Useful discussion on importing code into a subversion repository.
Useful external links
- Resolving conflicts - http://www.tutorialspoint.com/svn/svn_resolve_conflicts.htm
- Checking out a project in eclipse (via subversion) - http://help.collab.net/index.jsp?topic=/org.tigris.subclipse.doc/topics/checkout.html. The top level page http://help.collab.net/index.jsp?topic=/org.tigris.subclipse.doc/topics/add.html shows how to use subversion in eclipse. I found both to be very useful.