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.
acemtp : It on demand. I know the svn command (it s easy to find them eveyrwhere). The question is to know how to use that in a .bat scriptacemtp : I don't want to put the status into a log file :) I want the code of the .bat that do something like: if(svn_changed()) do this else do thatFrom Jonathan Lonowski - Working Copy
-
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. ;-)
acemtp : Thank you very much. It's perfect, I'll test that ASAP.acemtp : In fact, it doesn't work. For example, svn status returns some line with: ? files M files2 that are local modification or files that are not in the repository. I only want to have see "Changed files" when there s some repository changes.acemtp : I posted the answer with a modified versionTooony : Then I am not sure I understand what you want to do here... Do you want to perform a svn update, and if something has changed in the svn server repository, you want to perform a build with the new code? Or is it if something has been modified locally you want to rebuild? If 1: What about conflicts?From Tooony -
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! )
From acemtp -
Have your .bat execute
svnversion
(if you're using Subversion) orSvnWCRev.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.From antik
0 comments:
Post a Comment