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.
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
.