A better SVN on a Mac

For a couple of projects, I’ve started using Subversion instead of CVS. I was never a big connoisseur of CVS, and there are plenty of people out there already extolling the virtues of SVN over CVS, so that’s not what this is about. Instead, I want to post a couple of things that help make SVN more “Mac-like” for me.

I should point out that both of these have been done before, and really I’m only collecting together some details I’ve found. While I do tend to write my code in Xcode, due to the multi-platform nature of the projects I don’t actually use Xcode’s project format. Instead, I compile through Terminal.app and likewise manage SVN through it. As nice as the terminal is, it’s nice to have some more “graphical” interface when possible.

Setting your $EDITOR

The first change is to set the the $EDITOR environmental variable to an application of your choice:

export EDITOR="/usr/bin/open -n -W -a /Applications/TextEdit.app"

Put this line in your Bash profile, the file conveniently called ~/.profile . Here I’ve set it to be TextEdit, but any text-editing application might work (I had also considered Smultron). You can also set it to any X-Windows application, such as XEmacs:

export EDITOR=/sw/bin/xemacs

(I have XEmacs installed with Fink). In Leopard, X11 will open up automatically as necessary.

But let’s get back to that open command and go through the flags in use.

  • -a lets you specify which application to use to open the file that will be passed (and should be followed by the absolute path to the app you want). Potentially, you could also use -b to give it the bundle identifier for the application in question, but I am less familiar with how to figure out what bundles to specify with this.

  • -n opens up a new instance of the application in question. So if I already have a copy of TextEdit open (not really likely), it opens up a second copy. This goes together with the next flag to get this to actually work.

  • -W tells the open command to stay open until the application in question quits (otherwise, it would exit after TextEdit opened).

The -n and -W are the real magic here. If you try to do a committal in svn, a la

svn commit

a temporary file is made and the $EDITOR variable is used to open it. Once the $EDITOR program quits, it uses the contents of the temporary file for the log. So now you just need to remember to quit TextEdit when you’re done writing the log message.

Using Filemerge.app instead off diff

I happen to like FileMerge. It doesn’t do as smart a comparison of files as I’d like sometimes, but I don’t think it’s any worse than regular diff. Instead of reprinting what someone else has already done for me, I’ll send you to a link to bbum’s site (who I believe is involved in the wonderful Fink project). I should point out this is an update to an original idea by Michael Ash, I just find this modification more refined. Now, when you type

svn diff somefile

instead of outputting to the terminal, FileMerge opens! It is supposed to also work in the case of conflicts, but I haven’t been unfortunate enough to have to use it for that, yet.

Technorati Tags: , , , ,

Comments

Popular posts from this blog

Xcode 3 language specification changes

Redux on iPhone and iPod Touch, 802.1X and LEAP

iPhone and iPod Touch, 802.1X and LEAP