Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Current Subversion revision command

Tags:

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.

like image 232
creativz Avatar asked Jan 02 '10 12:01

creativz


People also ask

How do I revise in svn?

"svn info --show-item revision" will give the current revision to which the current directory is updated.

What is svn revision?

Subversion, with the command line tool svn, is a revision control system, also known as a source code management system (scm) or a source code control system (sccs). The subversion server maintains a repository, where files are stored in a hierarchy of folders, same as a traditional file system.


2 Answers

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.

like image 139
BastiBen Avatar answered Sep 20 '22 20:09

BastiBen


There is also a more convenient (for some) svnversion command.

Output might be a single revision number or something like this (from -h):

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

I use this python code snippet to extract revision information:

import re import subprocess  p = subprocess.Popen(["svnversion"], stdout = subprocess.PIPE,      stderr = subprocess.PIPE) p.wait() m = re.match(r'(|\d+M?S?):?(\d+)(M?)S?', p.stdout.read()) rev = int(m.group(2)) if m.group(3) == 'M':     rev += 1 
like image 45
Saulius Žemaitaitis Avatar answered Sep 18 '22 20:09

Saulius Žemaitaitis