SvnHelp >

  1. Set up and optimize SVN to access the GCC repository.

  2. A conceptual introduction to SVN for CVS users.

  3. SVN Basic commands.

  4. Moving patches around: merging and backporting.

  5. How to maintain a branch.

  6. Various tricks and recipes.

  7. Troubleshooting.

Various tricks and recipes

How can I get a list of the branches or of the tags?

$ svn ls svn://
$ svn ls svn://

Which is the revision of my tree?

$ svnversion .      # additional tool shipped with SVN clients

=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://

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://          # 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:


# Additional -F for .md files

# 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} "$@" ;;

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.:

# 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:// | 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:

export repo

Or csh/tcsh:

setenv repo svn+ssh://

and then you can use it as in:

$ svn ls $repo/tags

I'm also tired of always typing Am I able to set a default username?

Create or modify your ~/.ssh/config file to contain:

  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


$ 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

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
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://

None: SvnTricks (last edited 2014-11-07 16:34:01 by ManuelLopezIbanez)