Quick script to fetch diff history [of a file] using svn
If you wanna see the whole history differences of some file in svn repository, you could use this:
$ svndiffhist file
Retrieving releases...
OK (found 17 steps)
## 908:895
diffs...
## 895:890
diffs...
## 890:880
... etc
Where svndiffhist is the following script:
function svndiffhist {
FILE=$1
echo -n "Retrieving releases..." >&2
releases=$( svn log $FILE | grep '^r[^a-z]' | cut -d " " -f1 |
cut -dr -f2- )
num_steps=$( echo $releases | wc -w )
echo -e "tOK (found "$num_steps" steps)" >&2
# Sort them in ascrending order
#releases=$( echo $releases | tr " " "n" | sort -n )
# Group them as A:B B:C C:D
releases=$( echo $releases | sed 's/ ([0-9]+)/:1 1/g' )
for EACH_STEP in $releases; do
#svn diff -r $EACH_STEP $FILE | gvim -
echo "## $EACH_STEP" >&2
svn diff -r $EACH_STEP $FILE
done
}
on June 16th, 2009 at 10:42 am
On my local instance I have to set the delimiter (-d ‘|’) for the first cut on grabbing releases, so it reads:
releases=$( svn log $FILE | grep '^r[^a-z]' | cut -d '|' -f1 |
cut -dr -f2- )
on June 16th, 2009 at 2:47 pm
Hi Emanuele,
Thanks for pointing that out!
Actually, when pasting the script, I missed a ‘\’ backslash… (I was delimiting it by space rather than ‘|’).
Post fixed.