no conflicts with hg merge but conflicts with kdiff3

Mads Kiilerich mads at kiilerich.com
Thu Oct 14 12:42:05 UTC 2010


On 10/14/2010 02:19 PM, b b wrote:
> Hi,
> firstly, I'm mercurial newbie, so please bare with me.
> I looked at my problem one more time and that what I saw in the kdiff3
> weren't conflicts, kdiff did say "resolved conficts 15" and "unresolved
> 0", I did interpret it incorrectly. So he solved the conflicts
> automatically as mercurial did.
> But my question remains, why mercurial merges the files although there
> are conflicts (at least I think there should be conflicts).
> Here is an small example:
> Certainly you know the hginit.com <http://hginit.com> Tutorial. On the
> second half of the page http://hginit.com/02.html there is an merge
> example. Those two file differ only in last line. One file has "Serve
> with *potato* chips." and the second
> has "Serve with *tortilla* chips."
>
> Now, both file are merged with no conflict:
> *hg merge*
> merging guac
> 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
> (branch merge, don't forget to commit)
> The line after merge looks like this "Serve with *potato* chips."
> That's the same what happened to me, why is there no conflict, why took
> mercurial automatically "potato" and not "tortilla"?
> I think in such a case, the user has to resolve such a conflict
> manually, or am I wrong?

Mercurial is smart. It doesn't just merge the two files, but it finds 
the last version the files had in common before they diverged. In this 
case it can see that it started out as tortilla, one edit preserved that 
while the other changed that to potato, and it concludes that potato wins.

As the quide you referenced says:

> In this case, since we both edited different parts of the file,
> there was no conflict at all and the merge went off without a hitch.

It can be a bit confusing but convenient that Mercurial automatically 
and silently tries to merge before launching the merge tool. You can 
disable that by adding to your merge-tools configuration that 
kdiff3.premerge=False

/Mads



More information about the Mercurial mailing list