I have a .bat and inside the .bat i would like to execute a special code if there's some modification inside the svn repository (for example, compile).
Are you wanting this to be reactive? Or, on-demand?
For reactive, see hooks. The script will have to be named according to it's purpose: pre-commit.bat, post-commit.bat. The scripts are called as: [script] [repos-path] [revision-number]
For, on-demand:
- Working Copy
- svn log
- svn st
- svn diff
- svn proplist
- Repository
- svnlook author
- svnlook changed
- svnlook date
- svnlook diff
- svnlook history
Example:
svn st "C:\path\to\working\directory\" >> C:\path\to\working\project.log
Every time you run the BAT, it'll add the st output to project.log. Adjust as needed.
For Win 2000 and later, this would assign the last output row from the svn status commmand to the svnOut variable and then test if the variable contains anything:
@echo off
set svnOut=
set svnDir=C:Your\path\to\svn\dir\to\check
for /F "tokens=*" %%I in ('svn status %svnDir%') do set svnOut=%%I
if "%svnOut%"=="" (
echo No changes
) else (
echo Changed files!
)
Why there is a line like this
set svnOut=
you have to figure out yourself. ;-)
Ok, the solution I found with the help of Tooony:
set vHEAD = 0
set vBASE = 0
set svnDir=<path to local svn directory>
for /F "tokens=1,2" %%I in ('svn info -r HEAD %svnDir%') do if "%%I"=="Revision:" set vHEAD=%%J
for /F "tokens=1,2" %%I in ('svn info -r BASE %svnDir%') do if "%%I"=="Revision:" set vBASE=%%J
if "%vBASE%"=="%vHEAD" (
echo No changes
) else (
echo Changed files!
)
Have your .bat execute svnversion
(if you're using Subversion) or SvnWCRev.exe
(if you're using TortoiseSVN) against the top-most level of your working copy.
Both output if your working copy has been modified.
svnversion
appends a "M" to its output.
SvnWCRev.exe
will print a line of text that the WC has been modified.