views:

56

answers:

1

I'm interested in understanding two-way and three-way merging of source code files. Based on what I've read, two-way merging has some "crippling weaknesses" compared to three-way merging. What I'd really like to see are one or two simple, concrete examples of cases where three-way merging is able to automatically merge something from a branch to the trunk without producing conflicts, while two-way merging falls down and requires a bunch of manual intervention to get the code merged.

Any links to blog posts or even references to books would be appreciated (yes, I have Googled this for an hour or so). Thanks!

A: 

If you have a file and one person adds a line to it but another person removes a line from it, two way merging between the two changed versions will tell you that they're different but not what to do to "reconcile" the changes; the diff will show two additional lines in one of the files so if you don't know what the changes were it may not be clear what the merge should be.

Three way merging, on the other hand, clearly indicates that one line was removed and one was added. There's no ambiguity when you can see both versions of the file's differences from their common ancestor.

dash-tom-bang