Mercurial - 始终将本地文件与特定文件夹匹配

Mercurial - Always take local for files matching on a specific folder

我需要设置 Mercurial HG,以便始终 take local 匹配特定文件夹中的文件版本。

EG:when conflict on /**/dist/ always take local

这是因为我需要提交一些构建的文件。 提前致谢

编辑:

我需要提交一些由某些处理器(libsass、webpack)生成的文件,这取决于我的构建系统暂时不可用。所以,我从 hgignore 中删除了这些文件。现在,我遇到的问题是这些生成文件的 Mercurial 冲突 我想使用这些文件的本地版本自动进行合并解析。 类似于:How to keep the local file or the remote file during merge using Git and the command line? 但对于 Mercurial HG

您可以在 ~/.hgrc.hg/hgrc 中放置一个合并模式来为给定文件指定合并的默认工具:

[merge-patterns]
**/dist/* = :local

:local 合并工具将优先考虑本地版本。有关内部合并工具的完整列表,请参阅 hg help merge-tools。请注意,在合并期间使用 --tool 选项将覆盖此选择;但是,设置 ui.merge 选项来定义默认合并工具不会。

**/dist/* 模式可能是您需要的,也可能不是。请根据您的需要进行调整(请注意,如果需要,正则表达式模式也可用于提供额外的灵活性)。

或者,您也可以在合并后自动解析这些文件,例如有:

hg resolve --tool :local $(hg files -I '**/dist/*')

或者,如果文件列表太大而不适合命令行:

hg files -0 -I '**/dist/*' | xargs -0 hg resolve --tool :local