简体   繁体   中英

Piping subversion revision numbers to diff

OK, so I can run a command like this to get a list of revision numbers made on a certain date or date range:

svn log -q -r{2012-01-25}:HEAD | grep '^r[0-9]' | cut -d\| -f1 | cut -b2-

This works fine and gives me a list like this

12345
12346
12347

Now, I would like to pass these revision numbers to the diff command, so running a simple svn diff on a revision number manually works as expected ie

svn diff -c12345

But, if I attempt to pipe the revision list to the diff command like this

svn log -q -r{2012-01-25}:HEAD | grep '^r[0-9]' | cut -d\| -f1 | cut -b2- | xargs svn diff -c

it returns an error that the node was not found - looks to me like I am passing the arguments wrong.

It looks like, in the last part of the pipe, xargs is trying to execute:

svn diff -c 12345 12346 12347

when it should try:

svn diff -c 12345
svn diff -c 12346
svn diff -c 12347

because the -c option only accepts one argument.

To fix that, try to replace xargs with xargs -n1 .

The problem is that each of 12345 , 12346 , 12347 is passed as a separate argument; you need it to be joined with the -c into a single argument.

Assuming you're using the GNU findutils version of xargs , you can use the -I option. An example not using svn:

$ printf "12345\n12346\n12347\n" | xargs -n 1 -I{} echo svn diff -c{}
svn diff -c12345
svn diff -c12346
svn diff -c12347

Note that this invokes svn diff once for each version number. Your command invokes svn once with multiple version numbers. If you want to invoke svn once for multiple version numbers:

svn diff -c12345 12346 12347

then a different solution will be necessary.

EDIT :

Reading the other answer and the svn documentation, it looks like you can have a space after -c , so either svn diff -c12345 or svn diff -c 12345 is valid. In that case, just using -n 1 should do the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM