A couple of years ago, I was working with a guy who write a little script that I’ve found completely invaluable. It simply did the following:
- Accepted a filename of a file in a svn working copy tree.
- Grabbed the previous checked in version of the file.
- Opened the two files in the Filemerge utility on a mac.
Filemerge is a great utility for looking at diffs side by side. From the command line, you use the opendiff command to get at it via scripting.
- svn log
This will print out a list of the commits that the file has been associated with. Your most concerned with the first commit listed in the log (which represents the last commit). Grab the hash for that commit. Should look like this:
- svn ls-tree
This will list the files associated with that commit and give you the hashes for the particular version of that file. Grab the hash for the particular file you’re interested in. Should look like this:
100644 blob 342c0eacda335f17d21275f657e827c83e5e3f48 filename
- svn show -p
This will print to stdout the contents of that file at that version. This is what we’ve been looking for.
Viola. Now I have the contents of the previous checked in version of the file and am happy as a clam. I was able to get the script working after that.