3 way merging 3

Posted by scientific on February 24, 2007


I use Subversion to manage source code. Subversion does a pretty good job in handling multiple branches of code and generally keeping things orderly. But it doesn’t seem to do a very good job in merging branch lines back together. To do that properly you really need the help of a three-way merge tool. So today I set out to review some commonly available tools to see what’s what.

The reason you want a three way merge is because every file that you branch, in effect, has three copies. 1) The copy of the file as it was just prior to the time you made the branch: this is the “ancestor” copy. 2) The copy of the file as it exists in the external branch that you’re merging into the code you’re currently working on. 3) The copy of the file in the branch which you’re actively using.

Now managing which is an “active” branch, and in which direction you should merge to/from is beyond the scope of this little review article. (But in general merging from trunk to branch first is usually a good plan, and then back from branch to trunk if your development lifecycle calls for it.)

To test the third party tools out there, I built a reasonably complicated test case with three simple text files that had various changes in them – some of them could reasonably be figured out, some you’d have to be smart to figure out, and some were conflicts that were definitely ambiguous in terms of priority. Here was the general types of conflicts I set up:

1) External branch added a line after branching
2) Working branch added a line after branching
3) External and working added different lines to the same place (I would want to keep both changes)
4) External and working changed the same line in the same place (I would want to choose which to keep)

I felt like this was a pretty reasonable set of conflicts that I have in my day to day programming life.

Here are the results of my very quick and informal merge analysis:

Araxis:
Great UI for conflict resolution. Merge function is smart, and it has such a great interface that you almost don’t resent doing the remaining work yourself. It costs $150 which is double Guiffy and treble ECMerge. KDiff3 is free.

Guiffy:
Worse UI (does anyone prefer the Java GUI to native platforms?) Website claims that it has extra logic not available to other tools. This is snakeoil – this tool couldn’t figure out the merges that other tools handled fine. Not impressive.

KDiff3:
Nice clean UI for viewing conflicts. Interface for resolving conflicts is clunky and there are some hidden features that I had to guess at (you work with three files A,B,C -> if you want the changes from C followed by the changes from B, you click the button “C” then hold shift and click “B” – if you want to swap from C to B, don’t hold down shift and do the same thing). Exactly as smart as Araxis. Overall the interface for resolving conflicts is mildly annoying but workable – it’s easy to read anyway. Given that it’s a free tool, this tool is highly noteworthy.

Ellie Computing (ECMerge):
Cluttered interface (tons of buttons all over the place). Exactly as smart as Araxis and KDiff3. It had the best functions for resolving conflicts although it’s interface is visually “loud”: it offers functions such as “merge left than right” or “right than left” or “merge inline but prefer right” – these were great options to get the merged code close to final – it’s obvious that the people who built this tool have gone beyond the computer science problem of merging: they realize that real people have to merge and have tried to put interface shortcuts to help you do it.

All the tools allow you to go into the output area and make manual changes to the finished merge to get it exactly right: this is a critical feature. KDiff3’s output window is a little more cluttered b/c of merge messages that are inserted into the output window (but not into the output file when its saved).

Although I didn’t expect this, the overall winner in my opinion, is ECMerge (which I didn’t have any hope for at all based on the crappy website and other poor marketing indicators – just goes to show you). I really liked Araxis’s interface and KDiff3’s did the job.

What I want in a tool is to clear conflict visualization and ease of use in getting the merger to do what you want. Three of the four products accomplish that very well (Guiffy would do in a pinch but I was disappointed in it, and had thought it would do better than it did).

As a bonus, ECMarege, Guiffy and Araxis all have “undo” features which unwind the commands on the output file. So it’s easy to try something out and see what happens and go back if it’s not working. KDiff3 doesn’t seem to support this, and it turned out to be really useful in my testing anyway.

That’s what I’ve learned today, playing around with merge tools. I hope this information is helpful!

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. Bill Ritcher Sat, 26 May 2007 10:59:27 UTC

    The Guiffy SureMerge 3-way auto merge algorithm is NOT “snakeoil”.

    There are still 3-way merge tools out there that don’t detect lines inserted at the same point in the code as a conflict. One of these merge tools will detect fewer conflicts. But, it would be a mistake to think of them as “smarter” because the user has fewer conflicts to resolve.

    Guiffy’s 3-way merge applies a proprietary algorithm which is not based on unique anchor file compare algorithms used by other merge tools. The sureMerge algorithm avoids the worse case scenarios which can happen when the set of unique anchors are not the same for all 3-way compares. In such cases even the authors of those algorithms admit reconciling the compare results for the auto-merge is problematic. Thats another way of saying — its impossible to get it right all the time.

    Guiffy’s SureMerge 3-way algorithm treats changes which are close to each other but not acutally overlapping as Attentions (conflicts). Yes, this can result in more Attentions than conflicts. But, by reviewing these changes, the merge user will be more confident of their merge result.

    The White Paper on our web site includes simple test case file sets for evaluating 3-way merge tools. If you use those test files with other merge tools (such as those menthioned in your post), you will see how Guiffy SureMerge produces more trustworthy merge results.

    We have many other much more complicated “ugly merge” cases which we’ve collected over the years from users of other merge tool failures which SureMerge processes properly.

    Please, if you have any 3-way merge cases which you’d like to discuss further — let me know.

  2. science Sat, 26 May 2007 15:04:12 UTC

    Bill, your company’s tool failed to merge some files that other tools handled correctly. I can see your point that if your tool is more cautious and flags more things as unresolvable, then it will make fewer mistakes. But what I wanted to convey to anyone who reads this article is that your tool will make them do more work in non-trivial (but non-heinous) merge cases. I can imagine that tools which make life easier for such “intermediate difficulty” cases won’t work well in very complex merge situations.

    So there’s a balance: perhaps your tool works very well for very difficult merge situations? For scenarios like the one I tested, where there are some complex but not unmanageable merge situations, your tool made me do work which most of the other tools I evaluated didn’t make me do. A classic trade-off.

    Thanks for your input on the subject.

  3. Paulo Eduardo Neves Tue, 16 Sep 2008 06:01:31 UTC

    Another nice and free (as beer) tool is Source Gears Diff Merge: http://www.sourcegear.com/diffmerge/

Comments