Current Subversion revision command

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

    Use something like the following, taking advantage of the XML output of subversion:

    # 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')
    

    Note also that, depending on what you need this for, the entry may be more what you're looking for. That gives the "Last Changed Rev", which won't change until the code in the current tree actually changes, as opposed to "Revision" (what the above gives) which will change any time anything in the repository changes (even branches) and you do an "svn up", which is not the same thing, nor often as useful.

提交回复
热议问题