Current Subversion revision command

后端 未结 10 2248
日久生厌
日久生厌 2021-01-31 13:05

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.

10条回答
  •  轮回少年
    2021-01-31 13:52

    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
    

提交回复
热议问题