mercurial - Mercurial 如何在内部 merge ?

标签 mercurial branching-and-merging

quora 上有一篇关于 git 如何 merge 的漂亮文章:
http://www.quora.com/Git-revision-control/How-does-git-merge-work

我想知道 Mercurial 是否存在这样的事情。

我承认我这样做的动机是 Mercurial 在自动解决冲突方面似乎非常愚蠢,但是没有关于 mercurial 如何 merge 的具体信息,我无法为 Git 提出论据。 (也可能我疯了,方法是一样的,不管我在任何地方都找不到关于 HG 如何 merge 的信息。)

我也听说 HG 是 super 可配置的,所以如果有一种工具可以使 merge 不那么愚蠢,我很想听听。

作为 HG 似乎所做的愚蠢的一个例子,它与其他空值产生了许多冲突,例如:

<<<<<<<< local
[some new code...]
========
>>>>>>>> other

编辑:所以,我也在寻找一种可以智能地自动解决冲突的 merge 工具。就像,它应该能够解决上面的例子,解决起来非常简单。

最佳答案

Mercurial 在很大程度上将 merge 留给了外部程序。看
https://www.mercurial-scm.org/wiki/MergeToolConfiguration

https://www.mercurial-scm.org/repo/hg/help/merge-tools
从最后一页:

Mercurial uses these rules when deciding which merge tool to use:

  1. If a tool has been specified with the --tool option to merge or resolve, it is used. If it is the name of a tool in the merge-tools configuration, its configuration is used. Otherwise the specified tool must be executable by the shell.

  2. If the "HGMERGE" environment variable is present, its value is used and must be executable by the shell.

  3. If the filename of the file to be merged matches any of the patterns in the merge-patterns configuration section, the first usable merge tool corresponding to a matching pattern is used. Here, binary capabilities of the merge tool are not considered.

  4. If ui.merge is set it will be considered next. If the value is not the name of a configured tool, the specified value is used and must be executable by the shell. Otherwise the named tool is used if it is usable.

  5. If any usable merge tools are present in the merge-tools configuration section, the one with the highest priority is used.

  6. If a program named "hgmerge" can be found on the system, it is used - but it will by default not be used for symlinks and binary files.

  7. If the file to be merged is not binary and is not a symlink, then "internal:merge" is used.

8.The merge of the file fails and must be resolved before commit.

Note: After selecting a merge program, Mercurial will by default attempt to merge the files using a simple merge algorithm first. Only if it doesn't succeed because of conflicting changes Mercurial will actually execute the merge program. Whether to use the simple merge algorithm first can be controlled by the premerge setting of the merge tool. Premerge is enabled by default unless the file is binary or a symlink.

关于mercurial - Mercurial 如何在内部 merge ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21637143/

相关文章:

windows - 在 Windows 上升级到 Mercurial 更高版本 : Cannot clone a repo: get abort message because cannot find web. cacerts

git - 尽管有更改,但尝试 merge 分支会返回 'already up to date'

tfs - 是否有命令行 TFS 工具来跟踪分支之间的变更集?

mercurial - Mercurial 书签和 Evolve 主题有什么区别?

apache - Mercurial 更新导致临时端口读/写问题

mercurial - 如何删除已推送的 Mercurial 提交?

ios - Xcode 框架版本/当前/标题/错误

git - 如何将bugfix分支 merge 到Master分支?

git - 如何删除已发布的分支而不在 github 控制台上创建 pull 请求

TFS 分支推荐