views:

81

answers:

2

I'm using svn in a script (Windows scripting .cmd file).

Currently it checks out all files to a folder, then iterates that folder adding all the files to a master file as part of a build process. Something like:

svn checkout --username %username% %SVNURL% %workingfolder%
FOR %%i IN (%workingfolder%\*.*) DO TYPE %%i >> %DESTFILE%

What I would like to do for builds after the inital build is produce a "change" file, that only has the files included which have changed since the last build.

I can use the svn update command instead of checkout, and this gives me a list of files being updated. svn update Reference (svnbook.red-bean.com)

What I would like to do is iterate this list of results from the svn update, find these files within the working folder and copy them to a change file.

A: 

You can find updated files pretty easily:

svn up | findstr /r /c:"^U"

You can iterate over the output of that with the for command:

for /f "tokens=2* delims= " %%x in ('svn up ^| findstr /r /c:"^U"') do copy "%%x" change
Joey
Thanks, have read up on all commands in use there, currently trying to get this to work: for /f "tokens=2* delims= " %%x in ('%SVNExecutable%svn up --username user.name %SVNURL% %procsfolder% ^| findstr /r /c:"^U"') do ECHO %%xProblem is that %SVNExecutable% includes a space in the path (Program Files) and so this errors ('C:\Program' is not recognized ....). Tried comments around %SVNExecutable% but that doesn't work...any way I think your answer is correct, so thanks, any further help gratefully received: how can I escape the space?
DannykPowell
Quotes around the argument to `copy` should suffice. Sorry, I forgot them. Can't test here right now with file names with spaces, though, but the `for` statement should work correctly.
Joey
A: 

Apologies for answering my own question, this is also only a partial answer but it's where I'm at currently.

Firstly, the problem with the spaces is not just with the file path in %SVNExecutable%, the problem is with spaces in the command at all.

The way to solve this problem (works on windows XP) is to use the usebackq switch, and use back quotes ` instead of normal quotes. Using this, I have managed to get the svn update command to work:

for /f "usebackq tokens=2* delims= " %%x in (`%SVNExecutable%svn up --username %username% %SVNURL% %workfolder%`) do ECHO "%%x"

This updated the test file, and from an initial update result of:

U    full\path\to\file\file.sql
Updated to revision 36793.
Summary of conflicts:
Skipped paths: 1

This produces a result of:

"full\path\to\file\file.sql"
"to"
"of"
"paths:"

The last remaining piece of the puzzle that I can't get to work is the findstr with regex. When I add this back in and try this:

for /f "usebackq tokens=2* delims= " %%x in (`%SVNExecutable%svn up --username %username% %SVNURL% %workfolder% ^| findstr /r /c:"^U"`) do ECHO "%%x"

I get this error:

The filename, directory name, or volume label syntax is incorrect.

Was in 2 minds whether to start this as a new question now I've marked this one as answered...anyway, all help gratefully received

DannykPowell