Current Subversion Revision Team

Is there a Subversion command to display the current version number?

After svn checkout I want to run the script and you need the version number in the variable. It would be great if there was a command like svn info get_revision_number .

+42
svn
Jan 02 '09 at 12:55
source share
9 answers

You can use os.system() to execute the command line as follows:

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

I do this in my nightly build scripts.

There is also the svnversion command on some platforms, but I think I had a reason not to use it. Oh yes. You cannot get the version number from the remote repository to compare it with the local one using svnversion.

+70
Jan 02 '09 at
source share

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

The output may 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 am using this python code snippet to retrieve 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 
+21
Jan 02 '09 at 13:02
source share
  • First of all, svn status has version number, you can read it from there.

  • In addition, each file that you store in SVN can store a version number on its own - add the keyword $Rev$ to your file and run propset: svn propset svn:keywords "Revision" file

  • Finally, the version number is also in the .svn/entries file, fourth line

Now every time you check this file, it will have a revision itself.

+4
Jan 02 '09 at
source share

REV = svn info svn://svn.code.sf.net/p/retroshare/code/trunk | grep 'Revision:' | cut -d\ -f2 svn info svn://svn.code.sf.net/p/retroshare/code/trunk | grep 'Revision:' | cut -d\ -f2

+3
Mar 10 '15 at 8:01
source share

svn info , I believe this is what you want.

If you just need a revision, maybe you could do something like:

 svn info | grep "Revision:" 
+2
Jan 02 '09 at 13:00
source share

Use something like the following using subversion XML output:

 # parse rev from popen "svn info --xml" dom = xml.dom.minidom.parse(os.popen('svn info --xml')) entry = dom.getElementsByTagName('entry')[0] revision = entry.getAttribute('revision') 

Please note that depending on what you need it for, the <commit revision=...> entry may be larger than what you are looking for. This gives a "Last Changed Rev" that will not change until the code in the current tree actually changes, unlike "Revision" (as indicated above), which will change at any time when something in the repository changes (even branches ) and you do "svn up", which is not the same, and not so often useful.

+2
Jan 02 '09 at 14:38
source share

@Badcat's just used answer in a modified version using subprocess.check_output() :

 import subprocess revision = subprocess.check_output("svn info | awk '/^Revision:/ {print $2}'", shell=True).strip() 

I believe that you can also install and use pysvn if you want to use python to interact with svn.

+2
Oct. 15 '13 at 2:51 on
source share

Nobody mentions for Windows the world of SubWCRev , which, correctly used, can automatically replace the necessary data in the necessary places if the script calls SubWCRev in the form of SubWCRev WC_PATH TPL-FILE READY-FILE

An example of my hook after fixing (part)

 SubWCRev.exe CustomLocations Builder.tpl z:\Builder.bat ... call z:\Builder.bat 

where is my builder.tpl

 svn.exe export trunk z:\trunk$WCDATE=%Y%m%d$-r$WCREV$ 

as a result, each time I have a bat file with the variable part - name dir - which corresponds to the Work Copy metadata

+1
Jun 06 '13 at 21:34
source share

I think I need to do svn info, and then get the number by manipulating the string from "Edition: xxxxxx" It would be nice if there was a command that returns only a number :)

0
Jan 02 '09 at
source share



All Articles