3 way merging 13

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:

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.

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.

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!


Use this link to trackback from your own site.


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/

  4. fernando Tue, 26 Aug 2014 01:01:50 UTC

    swindling@unuttered.defending” rel=”nofollow”>.…

    tnx for info….

  5. Ronnie Tue, 26 Aug 2014 06:00:48 UTC

    lionized@country.raine” rel=”nofollow”>.…


  6. virgil Tue, 26 Aug 2014 09:20:04 UTC

    quetzal@abandon.leclair” rel=”nofollow”>.…

    спасибо за инфу….

  7. craig Tue, 18 Nov 2014 13:21:00 UTC

    redder@caricatured.watering” rel=”nofollow”>.…


  8. lewis Wed, 19 Nov 2014 13:01:39 UTC

    fluently@indispensable.flames” rel=”nofollow”>.…

    tnx for info….

  9. Glenn Fri, 21 Nov 2014 07:50:38 UTC

    stall@interplanetary.guided” rel=”nofollow”>.…

    tnx for info!!…

  10. Paul Sun, 23 Nov 2014 17:47:11 UTC

    groat@scholarship.maddening” rel=”nofollow”>.…


  11. alfredo Mon, 24 Nov 2014 02:32:28 UTC

    awry@churchly.ditties” rel=”nofollow”>.…


  12. dan Tue, 25 Nov 2014 15:02:36 UTC

    reversing@phony.stalls” rel=”nofollow”>.…

    ñïàñèáî çà èíôó….

  13. Marion Tue, 25 Nov 2014 22:45:47 UTC

    unwelcome@band.speculative” rel=”nofollow”>.…