Current Subversion revision command

后端 未结 10 2117
日久生厌
日久生厌 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:53

    Just used @badcat's 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 you can also, install and use pysvn if you want to use python to interface with svn.

    0 讨论(0)
  • 2021-01-31 13:57

    Otherwise for old version, if '--show-item' is not recognize, you can use the following command :

    svn log -r HEAD | grep -o -E "^r[0-9]{1,}" | sed 's/r//g'
    

    Hope it helps.

    0 讨论(0)
  • 2021-01-31 14:01

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

    0 讨论(0)
  • 2021-01-31 14:06

    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.

    0 讨论(0)
提交回复
热议问题