reading out the history of a file under svn

I found this code on the web a year or so ago – I ran into a situation where I needed to look through change on a file kept in version control in subversion, in detail. I needed what change was made, by whom, and the sequence in which the changes were made to trace down where a bug in the code appeared and disappeared. There was a period of time in which records were written to the wrong fields in a table. This could be recovered and reversed relatively easily with details as to when the change crept in, and then where it was fixed.

I found this scrap of code at stackoverflow.com

#!/bin/bash

# history_of_file
#
# Outputs the full history of a given file as a sequence of
# logentry/diff pairs.  The first revision of the file is emitted as
# full text since there's not previous version to compare it to.

function history_of_file() {
    url=$1 # current url of file
    svn log -q $url | grep -E -e "^r[[:digit:]]+" -o | cut -c2- | sort -n | {

#       first revision as full text
        echo
        read r
        svn log -r$r $url@HEAD
        svn cat -r$r $url@HEAD
        echo

#       remaining revisions as differences to previous revision
        while read r
        do
            echo
            svn log -r$r $url@HEAD
            svn diff -c$r $url@HEAD
            echo
        done
    }
}

history_of_file $1