6

I'm trying to get the revision information for the head using this command line

svn info https://myserver/branches/Code_Improvements -rHEAD | find "Revision"

However, this returns Revision : 1234

Since I'm using the result of the svn info command to set a variable in my batch file, is there a way I can get just the number 1234, instead of response Revision : 1234.

bahrep
  • 29,961
  • 12
  • 103
  • 150
this-Me
  • 2,139
  • 6
  • 43
  • 70
  • possible duplicate of [Getting the last revision number in SVN?](http://stackoverflow.com/questions/579196/getting-the-last-revision-number-in-svn) – bahrep Aug 20 '15 at 10:25

3 Answers3

12
  • Update Subversion client to 1.9 and use new --show-item option:

    svn info --show-item=revision URL-to-repository.
    
  • As an alternative, you can get the XMLed output of svn info using --xml option and use PowerShell to get the revision number. Here is a simple example:

    [xml]$revnum = svn info <REPOSITORY-URL> --xml -r HEAD
    $latestrevnum = $revnum.info.entry.revision
    $latestrevnum
    
bahrep
  • 29,961
  • 12
  • 103
  • 150
1

For the sake of completeness, if you need to get svn revision and then set it into a variable in a batch file (Windows):

FOR /f "delims=" %%R in ('svn info --show-item=revision URL-to-repository') do @set svnRevision=%%R
echo SVN revision: %svnRevision%
Alex Sanséau
  • 8,250
  • 5
  • 20
  • 25
0

I used this in order to get revision information in my case

for /f "delims=: tokens=1,2" %%a in ('svn info %SVN_REPO_URL%') do (
  if "%%a"=="Revision" (
    set /a RELEASE_REVISION=%%b
  )
)

Thanks @bahrep for an alternate solution. But the above snippet is what I used to get the version information in a variable.

this-Me
  • 2,139
  • 6
  • 43
  • 70