Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get svn revision information using command line on Windows

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.

like image 530
this-Me Avatar asked Aug 20 '15 10:08

this-Me


People also ask

How do I find my svn revision number?

To find information about the history of a file or directory, use the svn log command. svn log will provide you with a record of who made changes to a file or directory, at what revision it changed, the time and date of that revision, and, if it was provided, the log message that accompanied the commit.

How do I access TortoiseSVN from command line?

Locate TortoiseSVN and click on it. Select "Change" from the options available. Refer to this image for further steps. After completion of the command line client tools, open a command prompt and type svn help to check the successful install.

How do I view changes in svn?

To get an overview of your changes, use the svn status command. You may use svn status more than any other Subversion command. If you run svn status at the top of your working copy with no arguments, it detects all file and tree changes you've made.


2 Answers

  • 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
    
like image 183
bahrep Avatar answered Oct 16 '22 15:10

bahrep


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%
like image 29
Alex Sanséau Avatar answered Oct 16 '22 15:10

Alex Sanséau