views:

21

answers:

2

In order to view changes or diffs between commits, i use the following from the command line:

svn diff -r 3000:3025 > daychanges.diff

I want to modify the command so that it generates diffs between successive commits, concatenates them and outputs to file, something like

svn diff -r 3000:3001 > daychanges.diff
svn diff -r 3001:3002 >> daychanges.diff
svn diff -r 3002:3003 >> daychanges.diff
...
svn diff -r 3019:3020 >> daychanges.diff

how can i write such a script?

+1  A: 

You can write for loops in bash:

http://www.cyberciti.biz/tips/how-to-generating-print-range-sequence-of-numbers.html

Given that, it shouldn't be all that difficult to write a script that calls svn diff over a range of commits.

In a single line command, that could be run from the CLI:

for ((start=3000,finish=3001; finish<=3025; start++,finish++)); do svn diff -r $start:$finish; done > out.file

or if you prefer, the shorter version,

for ((i=3000; i<3025; i++)); do svn diff -r $i:$(($i + 1)); done > out.file

In a multi-line script:

#!/bin/bash
$begin=$1
$end=$2
$outfile=$3

for ((start=$begin,finish=$begin+1; finish <= $end; start++,finish++))
do
    svn diff -r $start:$finish
done > $outfile

(Omit the > $outfile if you just want to manually direct the output of the script.)

Amber
i havent run your version yet, but i wrote svn diff -r $(i):$(($i+1)) >> file inside the loop, and it works. thanks
+1  A: 

Should be something like:

diffs.sh:

#!/bin/bash
first=$(($1 + 1))
last=${2}
for i in `seq $first $last`
    svn diff -r $(($a - 1)):$a
done > daychanges.diff

then:

./diffs.sh 3000 3020
che