Using FileMerge with subversion

I have long wanted to use FileMerge as the target for svn diff operations on Mac OS X. But I was just too damned lazy to bother.

Fortunately, Mike Ash was not so lazy. Unfortunately, Mike’s simple/elegant solution titles the two versions of the file “tmp” and “tmp.2”.

This works fine if you have a short term memory span of more than about 30 seconds. I do not. My short term memory is more like that of a goldfish.

Mike’s script will also fail intermittently in that svn diff deletes the temporary files as soon as the command diffing them completes. That is often before FileMerge reads the files on my system.

So, I wrote a much longer and far less elegant script that puts the name of the file and version number into the title bar while also leaving copies of the renamed files in /tmp/svndiffshm-UID forever.

You can download the script from my personal subversion repository at red-bean.

To use, you can pass the –diff-cmd command line argument to svn diff. Personally, I want FileMerge to come up all the time.

For that, edit ~/.subversion/config. Uncomment the [helpers] line and [uncomment and] set the diff-cmd line to point to the script. It has to be an absolute path (I ought to file a bug against subversion about that).

Works for me. I’m sure someone will point out a far simpler way to do this.

Update #1: Ken Anderson pointed out that the script wasn’t working when using the generic svn diff command against a file with local modifications. Yup. Sure didn’t. Now it does. The link above will always lead to the latest version.

Update #2: Mark Rowe kindly submitted a patch to enable compatibility between and SVK. Patch applied. Changes comitted. Thank you. I really need to take some time to grok SVK. It appears to solve a number of problems that I run into daily, including the need for opaque collections.

Deprecated: link_pages is deprecated since version 2.1.0! Use wp_link_pages() instead. in /srv/www/friday/bbum/wp-includes/functions.php on line 4713

13 Responses to “Using FileMerge with subversion”

  1. Nat says:

    BBEdit’s Subversion integration works smoothly out of the box — there are “Compare with [Base|Previous|Head]” commands in the Subversion menu, which have completely upended my relationship with Subversion since I upgraded to BBEdit 8. FileMerge is no equal of BBEdit’s comparison tool.

  2. bbum says:

    Lots of people rave about BBEdit and it truly is an amazing piece of software. For better or worse (worse, in this case), I have emacs branded upon my soul from using it daily for nearly two decades (erp!). BBEdit’s “emacs compatibility mode” just doesn’t work quite right. The Cocoa text editing system does emacs key bindings quite nicely and, that combined with other idiosyncrasies I happen to have grown accustomed to, make it very difficult for me to switch away from an NSTextView based editor.

  3. Ken Anderson says:

    This doesn’t seem to work properly if ‘(working copy)’ is appended to the filename instead of (revision XX). Is anyone else having this problem? My regex is rusty…

  4. Christopher Elkins says:

    FWIW, I use a shell script bundled with svnX that accomplishes nearly the same thing (sans the revision in the title bar).

    Re: “It has to be an absolute path (I ought to file a bug against subversion about that).”

    That’s not my experience. I copied to a bin dir in my PATH and added “diff-cmd =” to ~/.subversion/config, and it worked just fine.

  5. mikeash says:

    I just noticed your post to my blog post, so I thought I’d reciprocate. It’s nice to see that someone got some use out of the post, and even nicer to see that it’s been improved upon.

  6. Mark Rowe says:

    I’ve tweaked to work correctly with SVK as well as Subversion. A patch is at

  7. Gavin Eadie says:

    You already noted that BBEdit didn’t fit the bill, and XCode, of course, has the same capability. I’ve found SvnX to be quite useful, though, again, no emacs !

  8. Lee Phillips says:

    Thank you for doing this! Having the diffs pop up in FileMerge is sweet!

    I put your script in /usr/local/bin and it worked without having to tell svn the path.

    I also have no use for BBEdit, and insist on Cocoa text entry (I use TextExtras). The nce thing is that if something better than FileMerge comes along your script can easily be modified to use that.

  9. Ron says:

    I know the post is really about SVN, but I couldn’t resist.

    MythBusters did a show where they tested the ability of gold fish to remember and found it was considerably longer than 10 or 30 seconds. Like days.

  10. Clever Name TBD says:

    FileMerge and Subversion

    Bill wrote up a blurb on using FileMerge with Subversion which reminded me that I had already written a couple of tools in that vein, so I’m posted them.

  11. Jim says:

    thanks Bill! FileMerge is pretty. 🙂 much better than this:

    return "%s-%s-%s" % (version,,'filename'))

    which, by the way, will fix things so that FileMerge gives you the function call pop-up menus for each file. FileMerge looks at the extension to determine the type of code it’s parsing, so you need to put the real filename last to have the pop-ups appear.

  12. Jim says:

    err.. I don’t know how to make these new fangled blog things work.

    replace the line that reads:
    return “%s-%s-%s” % (‘filename’), version,
    return “%s-%s-%s” % (version,,‘filename’))

  13. Mark’s Link Blog » links for 2007-10-03 says:

    […] bbum’s weblog-o-mat » Blog Archive » Using FileMerge with subversion (tags: development diff mac osx subversion tips svn) […]

Leave a Reply

Line and paragraph breaks automatic.
XHTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>