Kdiff 和 hg:自动合并后未解决的冲突

Kdiff and hg: Unresolved conflicts after auto merge

我们使用 Mercurial (+Tortoise Hg) 作为 VCS,使用 Kdiff 作为比较和合并工具。

有些文件是自动合并的,有时这个自动合并结果很奇怪:

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

似乎 kdiff 对文件中未解决的冲突没有做任何事情,而是将其标记为已解决。 也许 kdiff 有时不理解 diff 文件格式? hg 和 kdiff 集成中的一些错误?

这个问题好像也是最近出现的,可能是新版本的问题hg/tortoise hg/kdiff?

我们正在使用:

来自 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

更新:

即使手动合并也会出现问题。 步骤:

它就在这里! Parent 1(中心列)包含 'dest'、'source' 作为文件的一部分。但是这个文件中没有这样的行。

似乎 HG 向 kdiff 文件提供了一些 Kdiff 无法理解的差异信息。t/mustn

您显示的合并结果看起来非常像另一个合并工具的结果,即 internal:merge

由于您可以为不同的文件类型或文件配置不同的合并工具 - 或者明确地为特定合并提供合并工具 - 您确定您没有使用 kdiff 之外的其他合并工具吗?可能新的 tortoiseHG 版本(重新)定义了一些合并工具设置。

验证配置文件中合并工具的配置。请参阅 https://www.mercurial-scm.org/wiki/KDiff3 以了解它应该如何查找 kdiff3。方便引用:

[extensions]
hgext.extdiff =

[extdiff]
cmd.kdiff3 =

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

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

显示它! 我想查看 THG 的 Global Setting - TortoiseHG 选项卡(或 THG 的 repository-specific 设置)的屏幕截图,或者ini-file 的相关部分(更好,更短)。这是我的 mercurial.ini 的一部分,其中 p4merge 作为全局 diff-merge 工具

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

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

<<<<<<<>>>>>>>字符串是另一个合并的标志: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.

必须正确配置所选工具:KDiff3 是 GUI-tool, 显示在屏幕上 every-time 当无法自动执行合并(有冲突)并且这是你的职责时 - 在 KDiff window

中执行 hand-work 编辑结果

这是 Mercurial 3.6.0 和 3.6.1 中的错误。它已在 3.6.2 中修复。

  • 解决:仅在合并完全完成后恢复 .orig (issue4952)

引用原文:

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.