2
votes

We are using Mercurial (+Tortoise Hg) as VCS and Kdiff as diff and merge tool.

Some files are merged automatically and sometimes this auto merge result is wierd:

    public static Method()
<<<<<<< local
    {
        DoSmth();
    }
=======
    {
        DoSmth2();
    }
>>>>>>> other

Seems like kdiff has done nothing with unresolved conflict in file but marked it as resolved. Maybe kdiff doesn't understand diff file format sometimes? Some bug in hg and kdiff integration?

Also seems that this problem appeared recently, may be the problem with a new version of hg/tortoise hg/kdiff?

We are using:

  • Windows 7 x64
  • TortoiseHg and Mercurial 3.6.1
  • Kdiff 0.9.98

From mercurial.ini:

[ui]
merge = kdiff3

[tortoisehg]
editor=VisualStudio
vdiff=meld

[merge-tools]
meld.executable = C:\Program Files (x86)\Meld\meld.exe
meld.priority = 1
meld.premerge = False
meld.args = $local $base $other

[diff]
git = True

Update:

Problem appears even with manual merge. Steps:

  • Starting rebase
  • Tortoise Hg says: 'There are conflicts' Merge failed
  • Clicking "Tool resolve", Kdiff opens Kdiff nuans

And here it is! Parent 1 (center column) contains 'dest', 'source' as a part of the file. But there were no such lines in this file.

Seems like HG gives to kdiff file with some diff info that Kdiff can't/mustn't understand.

3
[merge-tools] is a) bad b) useless. Do you have kdiff in system? Can you run it by handLazy Badger
anyway, you have to have kdiff shown on conflictsLazy Badger
@LazyBadger - you are right, merge tools is useless in this case. But problem exists even without meld installed. And yes, I can run kdiff by hand and it opens on unresolved conflicts. See update for more strange info..VorobeY1326
I see dest + source lines in parent1 file. Check all sources in Working dir for this scrap (and, BTW, remove it) - it isn't merge-tool addition on the fly - now it's part of sourcesLazy Badger
Yes, this 'part of sources' remains in sources after merge. And I have to clean up it manually.. But - before merge/rebase there were no such lines in sources! They where somehow added during merge process.VorobeY1326

3 Answers

7
votes

It's a bug in Mercurial 3.6.0 and 3.6.1. It was fixed in 3.6.2.

  • resolve: restore .orig only after merge is fully complete (issue4952)

Quoting the original report:

Jonathan Little 2015-11-13 17:41:55 UTC

I have encountered the following problem introduced in Mercurial 3.6. I am running version 3.6+20151109 with TortoiseHG 3.6, but the problem appears to be in hg core (see my THG bug report: https://bitbucket.org/tortoisehg/thg/issues/4354) The behavior I'm seeing:

  • Set merge tool ([ui] merge in .hgrc/mercurial.ini) to internal:merge
  • Create a repository with two separate branches, with a change on each branch such that the changes conflict with each other.
  • Merge the two branch heads. internal:merge will leave the conflicting file with conflict markers.
  • Run "hg resolve --tool=kdiff3 ".

Expected result: KDiff3 correctly shows the shared ancestor content and the two conflicting revisions (see Expected.jpg).

Actual result: KDiff3 shows the shared ancestor revision and "other" conflicting revision correctly, but the local conflicting revision contains the merge markers from internal:merge (see Actual.jpg).

The problem occurs with THG's built in KDiff3 config, and with the built in KDiff3 config from mercurial/default.d/mergetools.rc. It does not occur with a barebones config consisting just of kdiff3.executable, but starts occurring when you add arguments and use $local. So it appears that the treatment of $local has changed to simply use the current local content of the file rather than the content on the merge parent from the local branch.

This behavior started with 3.6.0.

1
votes

The merge result which you show looks very much like the result of another merge tool, namely internal:merge

As you can configure different merge tools for different filetypes or files - or explicitly give the merge tool for a certain merge - are you sure that you didn't use another merge tool than kdiff? Possibly a new tortoiseHG version (re-)defined some merge tool settings.

Verify the configuration of your merge tool in your configuration file. See https://www.mercurial-scm.org/wiki/KDiff3 for how it should look for kdiff3. Quote for convenience:

[extensions]
hgext.extdiff =

[extdiff]
cmd.kdiff3 =

[merge-tools]
kdiff3.args = $base $local $other -o $output
1
votes

We are using Mercurial (+Tortoise Hg) as VCS and Kdiff as diff and merge tool.

Show it! I want to see screenshot of THG's Global Setting - TortoiseHG tab (or repository-specific settings of THG), or relevant part of ini-file (better, shorter). Here is part of my mercurial.ini with p4merge as global diff-merge tool

[ui]
merge = p4merge
...
[tortoisehg]
vdiff = p4merge

Some files are merged automatically and sometimes this auto merge result is wierd

<<<<<<< and >>>>>>> strings are signs for another merger: internal:merge3 with conflict markers

This is not generally recommended as Mercurial gets no direct feedback when merges are successfully completed, and it's not terribly user-friendly compared to modern tools.

You must configure selected tool properly: KDiff3 is GUI-tool, which will appear on screen every-time when merge can't be performed automatically (have conflicts) and it's your duty - perform hand-work of editing result in KDiff window