什么是three-way merge

A, B and C means three-way. C是A和B的父亲,D是A和Bmerge之后的结果

The three-way merge uses the ancestor of the changed files to identify blocks
of content that have changed in neither, one, or both of the derived versions.

使用C的内容来标记A和B的内容有没有改变(1.A和B都没有变,2.A或者B变了;3.A和B都变了)

Blocks that have changed in neither are left as they are. 如果是1的话,不需要merge。

Blocks that have changed in only one derivative use that changed version.
如果是2的话,D的内容和改变了的A或B一样。

If a block is changed in both derivatives, the changed version is used if it
has the same content on both sides,

如果是3的话,有分为两种,A和B的改动一样,则D的内容和A或者B一样;

but if the changes differ, it is marked as a conflict situation and left for
the user to resolve.

但是如果A和B的改动不一样的话,这时就会进入冲突模式,需要人去手动的解决了。

下图就是在clearcase中出现冲突后使用xmerge解决冲突的截图(相关code我已经隐去)。

http://en.wikipedia.org/wiki/Three-way_merge
http://en.wikipedia.org/wiki/Diff3
kdiff3. sourceforge.net