SvnHelp >
Various tricks and recipes
Contents
-
Various tricks and recipes
- How can I get a list of the branches or of the tags?
- Which is the revision of my tree?
- How can I find out which branch this working copy belongs to?
- How can I view the contents of a file at a given revision?
- How can I revert an offending commit?
- How can I get context diffs? How do I configure an external diff tool?
- Is there support for Emacs and/or xemacs?
- How can I speed up SVN?
- How can I reduce disk space usage?
- How can I get the revision number of a tag?
- These svn+ssh URLs are too long to type! What can I do?
- I'm also tired of always typing mygccuserid@gcc.gnu.org. Am I able to set a default username?
- Who changed/created this line of code? Who should I contact?
- Ordered diffs
- the update script is not working
- how can I remove the "-q" option?
- How can I get the diff for a single revision of a branch?
- How can I edit the commit log if, for example, I used the wrong PR number?
How can I get a list of the branches or of the tags?
$ svn ls svn://gcc.gnu.org/svn/gcc/branches/ $ svn ls svn://gcc.gnu.org/svn/gcc/tags/
Which is the revision of my tree?
$ svnversion . # additional tool shipped with SVN clients 105374M
=M= means that there are local modifies. Otherwise, you can find out the same with svn itself:
$ svn info | grep Revision Revision: 105374
Notice that you can use the keyword BASE as argument of --revision for all commands, to specify the revision of the tree without spelling it out.
How can I find out which branch this working copy belongs to?
$ svn info | grep URL URL: svn+ssh://giovannibajo@gcc.gnu.org/svn/gcc/branches/reload-rewrite
How can I view the contents of a file at a given revision?
$ svn cat --revision=345 gcc/reload.c # in a working copy $ svn cat --revision=345 svn://gcc.gnu.org/svn/gcc/trunk/gcc/reload.c # without a working copy around
How can I revert an offending commit?
Assuming the commit went in as r6600, the following is sufficient:
$ svn merge -r6600:r6599 .
How can I get context diffs? How do I configure an external diff tool?
The internal diff engine of Subversion supports only unified diffs, and it does not feature the dozen of options of GNU diff. You may want to use an external tool.
Edit ~/.subversion/config and specify the diff utilities to use as diff-cmd and diff3-cmd in the [helpers] section of that file. Then, to pass options to this diff command, you have to use the -x option, e.g:
$ svn diff -x -cp
will pass the options -cp to the external diff program.
This can get annoying pretty fast, so if you want to set default options for your diff command, you create a wrapper script, such as:
diff=/usr/bin/diff # Additional -F for .md files extra_args="-F^(define" # Do not pass multiple -c/-u options case "$1" in -c*|-C*) exec ${diff} -p ${extra_args} "$@" ;; -u*|-U*) exec ${diff} -p ${extra_args} "$@" ;; *) exec ${diff} -up ${extra_args} "$@" ;; esac
Then put this file as diff command to be executed in ~/.subversion/config and you are done.
If you get an error message like:
svn: /home/username/.subversion/config:37: Section header expected
, then you need to uncomment or create a section header first, e.g.:
[helpers] # editor-cmd = editor (vi, emacs, notepad, etc.) # diff-cmd = diff_program (diff, gdiff, etc.) diff-cmd = /home/username/bin/gccdiff
Is there support for Emacs and/or xemacs?
Sufficiently new versions of emacs have vc support for svn through vc-svn. You can also find it on Savannah vc-svn.el
Due to divergence between xemacs's vc and emacs's vc, vc-svn doesn't work with xemacs. There is also psvn, which should work on xemacs, available in contrib/client-side/psvn in the subversion source distribution.
How can I speed up SVN?
How can I reduce disk space usage?
These questions are answered in the SvnSetup page
How can I get the revision number of a tag?
To find out which branch and revision number the tagtags it's sufficient to do:
$ svn log -v -q --stop-on-copy svn://gcc.gnu.org/svn/gcc/tags/tree-ssa-post-merge | grep " A" A /tags/tree-ssa-post-merge (from /trunk:81764)
This shows us that /tags/tree-ssa-post-merge is a copy of /trunk at revision 81764
Note that for branches you must use /branch/gcc-4_1-branch
These svn+ssh URLs are too long to type! What can I do?
Use an environment variable to store the base address.
Like the following for Bourne based shells:
repo=svn+ssh://gcc.gnu.org/svn/gcc export repo
Or csh/tcsh:
setenv repo svn+ssh://gcc.gnu.org/svn/gcc
and then you can use it as in:
$ svn ls $repo/tags
I'm also tired of always typing mygccuserid@gcc.gnu.org. Am I able to set a default username?
Create or modify your ~/.ssh/config file to contain:
Host gcc.gnu.org User mygccuserid
Who changed/created this line of code? Who should I contact?
Just like CVS, you can do:
$ svn annotate FILE
or if you prefer:
$ svn blame FILE
or:
$ svn praise FILE
I consider this quite useful for discussing code. In SVN, it even works for past revisions --revision and branches!
Ordered diffs
CVS used to order diffs alphabetically with capitals first. Subversion currently doesn't. The following script will take a diff file as argument and output an ordered diff to the console. Be careful, as it doesn't check if its output overwrites its input.
for I in `lsdiff "$@" | LC_ALL=C sort`; do filterdiff -i $I $1 done
the update script is not working
The SCM independent method for updating your copy of the repo is to run the contrib/gcc_update script.
$ bash contrib/gcc_update Updating SVN tree svn: E155036: Please see the 'svn upgrade' command svn: E155036: Working copy '/u/gnu/proj/gcc' is too old (format 10, created by Subversion 1.6) Adjusting file timestamps Touching Makefile.in... SVN update of full tree failed.
Do as it says and run "svn upgrade". This may take a few minutes to a few tens of minutes, depending on your disk speed.
how can I remove the "-q" option?
Several contexts can wind up asking you to remove the -q option when you've never used any -q option. Somewhere, buried deep in nested commands, ssh is being invoked to perform some service. But it is not working correctly. The "remove the -q option" comment is telling you to have ssh invoked in a non-quiet mode in order to help debug the issue.
How can I get the diff for a single revision of a branch?
From your toplevel trunk checkout directory, do:
svn diff -cREVISION "^/branches"
How can I edit the commit log if, for example, I used the wrong PR number?
Assuming the revision is N
svn propedit 'svn:log' --revprop -r N svn+ssh://gcc.gnu.org/svn/gcc/