Current Subversion revision command

svn

Is there a Subversion command to show the current revision number?

After svn checkout I want to start a script and need the revision number in a variable. It would be great if there is a command like svn info get_revision_number.

Best Answer

Newer versions of svn support the --show-item argument:

svn info --show-item revision

For the revision number of your local working copy, use:

svn info --show-item last-changed-revision

You can use os.system() to execute a command line like this:

svn info | grep "Revision" | awk '{print $2}'

I do that in my nightly build scripts.

Also on some platforms there is a svnversion command, but I think I had a reason not to use it. Ahh, right. You can't get the revision number from a remote repository to compare it to the local one using svnversion.