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
}
Published
Categorized as Tech

Leave a comment

Your email address will not be published. Required fields are marked *