Getting current revision using svnversion

The svnversion command will tell you the revision of a working copy directory. For example, to query the revision of the current directory:

svnversion .

You'll either get a single number or two numbers separated by a colon or either of those two with an additional code. See the svnversion help page for information about the differences.

svnversion --help

Here's a snippet of the help page:

   4123:4168     mixed revision working copy
   4168M         modified working copy
   4123S         switched working copy
   4123:4168MS   mixed revision, modified, switched working copy

Using svnversion with merge

If you're doing a merge between one directory and another, you could call svnversion from the merge command by using command substitution.

For example, take the following scenario... You have a working copy that contains a) an up to date trunk with your latest code and b) a releases directory that contains various release branches, like so...

trunk
releases
releases/RB-2.0

You're currently in releases/RB-2.0 and you're sure that the revisions of the release and trunk are not mixed (i.e. a single revision number):

steph@slap ~/wcs/website/releases/RB-2.0 $ svnversion .
135
steph@slap ~/wcs/website/releases/RB-2.0 $ svnversion ../../../trunk
137

You can now call svnversion via command substitution in the svn merge command:

steph@slap ~/wcs/website/releases/RB-2.0 $ svn merge -r`svnversion .`:`svnversion ../../../trunk` file:///home/steph/repositories/website/trunk
U    themes/mindspill/layouts/default.html.erb

This of course is pointless if you already know the revision numbers, but it could be a useful shortcut if you already know the status of your working copy directories but you can't remember the revision numbers.

References

Last modified: 01/04/2009 Tags: (none)

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top