October 13, 2006
Merge tools

If you are going to be doing a lot of merging working with Subversion (or, I'd imagine, CVS), you are going to need good a good merge tool. And believe me, you are going to be doing a lot of merging.

Subversion itself doesn't provide a merge tool - and nor should it. It's a cross-platform command line driven tool, and besides, I suspect that most developers have their own favourite - or need to find one quickly.

If you are working on Windows, you'll probably have Tortoise installed, 'cos it's really good for simple stuff. Tortoise does come with a merge tool, but it's horrid, really nasty. Aside from just how damn ugly the thing is, it's also almost totally incomprehensible. All those colours - what do they mean?

But that's OK. There are alternatives, and they are easy enough to integrate into Tortoise. The first thing I came across was WinMerge. WinMerge is very good for showing diffs, but it doesn't (as yet) do three way merging - so that's out. Another, more powerful alternative is KDiff3. By the time I came across this, I'd already made my happy move to the Mac, so I've not used it myself, but my Windows-victim colleagues report that it works fine.

So the trick is to use the tool with diff in the name for merging, and the tool with merge in the name for diffing. ;-)

Tortoise also provides tools for making and applying patches, but they seem to use fully-qualified path names, so you can't apply patches from one machine to another unless it happens to keep everything in the same place. So, it's best to use Subversion to make your patches with svn patch > whatever.patch to make your patches (or svn st | awk '/^\s?[MAD]/ { print $NF } ' | xargs svn diff > whatever.patch if you've made the same externals mistake that I did), and to use unxutils' patch to apply them.

In the Mac, there's a natural solution - FileMerge, part of the XCode suite. It's very nice to use, if not perfect. (A few more keyboard shortcuts would be nice, for example, Apple, Just 'cos it's GUIfied and beautiful doesn't mean I should be reaching for the mouse all the time.) Integrating it with command line Subversion would be non-trivial but for Bruno De Fraine's lovely Using FileMerge as a diff command for Subversion - he's done all the hard work for you. Thanks for that, Bruno.

Oh, SubClipse also provides a merging tool, but I've never really used it. It's nice to have SubClipse around - the fact that it decorates all your files showing you their status against the repository is nice, and I often use it to add files - quicker than an svd add if you are in the IDE already. But IDE/version control integration is far less crucial than it used to be in the bad old VSS days when you couldn't edit a file without checking it out, so I do most of my Subversion tasks from the command line.

I'd be interested to know what all you *nix types use - especially anything console based.

Have I missed anything cool?

Posted to Software development by Simon Brunning at October 13, 2006 08:27 PM
Comments

On OSX I've used two tools:

SmartSVN
ZigVersion

SmartSVN is written in Java and can get quite sluggish, especially when it validates current locks against the repo. I have now moved to ZigVersion which is native OSX, much faster when updating from repos, but which has an interface which takes getting used to (it opens numerous windows and is not nearly as user-friendly as SmartSVN is, IMO). Both tools come with good merge functionality built in.

Posted by: Anthony Eden on October 13, 2006 09:33 PM

Araxis Merge is the best.

Posted by: joe on October 13, 2006 10:47 PM

http://meld.sf.net is what i have started using on linux. it displays the two "input" files to the left and right of the final file. i was convinced by the screenshots(after trying xxdiff eye candy was needed)..;]] also it seems to be one recommended by the mercurial people.

Posted by: betatim on October 14, 2006 01:18 AM

Check out svnmerge - a python wrapper around svn, it adds basic branch/trunk merge tracking.

Good write up here: http://kenkinder.com/svnmerge/

Posted by: Pete on October 14, 2006 02:59 AM

I use Meld all the time for two-way diffing and merging, and I like it very much. However, it's not good enough for three-way merging, because it does not show the differences between the left and the right pane, and that's important.

I too use KDiff3. It's not as nice and user-friendly as Meld, but it mostly gets the job done, and it's surely better than letting the VCS tool do a blind merge, and hoping all went right.

All this on Linux.

Posted by: Nicola Larosa on October 14, 2006 08:16 AM

I don't know if I'm lucky or what, but so far I've always preferred to edit a file with CVS-style conflict markers as a way to resolve merge conflicts.

Posted by: Marius Gedminas on October 14, 2006 02:10 PM

Perforce merge is my tool of choice with Tortoise SVN and it can be downloaded for free (just download the client install and choose to only install the merge tool).

http://www.perforce.com/perforce/products/merge.html

The merge tool that comes with Tortoise SVN is barely sufficient for any uses I have tried to put it to.

Posted by: Richard Tew on October 15, 2006 09:56 AM

have you given up java?
good to see you back again - I was just about to delete your bookmark :-)

Posted by: Harry on October 17, 2006 12:18 AM

Still Javaing much of the time, thanks, Harry. Python usage is growing...

Posted by: Simon on October 17, 2006 12:40 PM

Emacs features ediff and emerge, some of the most powerful (and best integrated tools) for the task. It allows you to perform a 3-way merge, and while it isn't as good looking as the Mac's FileMerge tool, it does intelligently highlight changes (including highlighting fragments within a changed line). Highly recommended!

Posted by: Lurker on October 19, 2006 08:23 AM

Warning: vendor comment

Our product, Guiffy SureMerge, works on MacOS X, Windows, Linux, Unix, and any Java enabled platform. Checkout our WhitePaper on Trustworthy 3-way auto-merge - it includes test file kits for evaluating 3-way merge tools.

Oh, the Guiffy UI has lots of toolbar buttons AND keyboard shortcuts.

http://www.guiffy.com

Posted by: Bill Ritcher on March 3, 2007 01:11 PM

Up-front, on-topic vendor comments welcome, Bill.

Posted by: Simon on March 15, 2007 02:21 PM

I use SvnX on Mac OSX as a GUI front-end to svn. It doesn't support merging directly but it has good support for viewing diffs in FileMerge.

Posted by: Kent Johnson on November 1, 2007 02:14 PM

By the way, when I'm cherry-picking parts of a patch (usually when I want to commit it as a set of smaller logical changes), vim's diff mode comes incredibly handy.

Posted by: Marius Gedminas on November 1, 2007 08:59 PM

thanks for the GREAT post! Very useful...

Posted by: Whatever-ishere on November 21, 2007 06:22 PM
Post a comment
Name:


Email Address:


URL:



Comments:


Remember info?