Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the current Revision number on command line via TortoiseSVN

I'm trying to write a batch file in which I need the HEAD revision of the project I am working on.

Is there a command to get this from the command line?

I am on a Windows XP Machine.

EDIT I ended up using a mix between Shambulator, mizipzor, and Stefan's answers. I ended up with this:

for /f "tokens=5" %%i in ('SubWCRev WorkingCopyPath^|find "Last committed at revision"') do set version=%%i 
echo %version%

Thanks for all your help guys

Added this answer to the list below as well.

like image 711
Nedloh Avatar asked Jul 05 '10 13:07

Nedloh


2 Answers

It's awkward without the text-processing capabilities of *nix, but this batch file does it:

@echo off
for /f "tokens=2" %%i in ('svn info -rHEAD svn://localhost^|find "Revision"') do @echo %%i

Substitute your svn repository for my svn://localhost.

svn info gets the repository info, then pipes it to find, which strips out everything except the line containing the revision number. The for command gives you the second "token" on that line (the first one is Revision:).

EDIT: As others have mentioned already, you'll need a command-line version of Subversion installed, and have svn.exe on your PATH.

like image 134
anton.burger Avatar answered Oct 23 '22 02:10

anton.burger


If you need that revision in a file, use SubWCRev which is installed with TortoiseSVN (or available separately).

like image 25
Stefan Avatar answered Oct 23 '22 01:10

Stefan