Mercurial 每种文件类型的合并策略
全部:
我想使用 kdiff 合并具有特定后缀(例如 *.c、*.h)的所有文件,并且我想对具有另一个后缀(例如*.mdl)。这样做的目的是允许我对特定文件类型使用一种“破坏合并”(即:不可合并的文件,如配置、自动生成的 C、模型等。)
在我的 .hgrc 中,我已经尝试过:
[merge-tools]
kdiff3=
clobbermerge=internal:other
clobbermerge.premerge = False
[merge-patterns]
**.c = kdiff3
**.h = kdiff3
**.mdl = clobbermerge
但它仍然会触发所有文件的 kdiff3 。想法?
其扩展是在目录上执行“破坏合并” - 但是一旦文件后缀的语法清晰,目录就应该很容易。
All:
I want to use kdiff to merge all files with a certain suffix (say *.c, *.h) and I want to do two things (turn off premerge and use internal:other) for all files with another suffix (say *.mdl). The purpose of this is to allow me to employ a type of 'clobber merge' for a specific file type (ie: un-mergable files like configurations, auto-generated C, models, etc..)
In my .hgrc I've tried:
[merge-tools]
kdiff3=
clobbermerge=internal:other
clobbermerge.premerge = False
[merge-patterns]
**.c = kdiff3
**.h = kdiff3
**.mdl = clobbermerge
but it still triggers kdiff3 for all files. Thoughts?
An extension of this would be to perform a 'clobber merge' on a directory - but once the syntax is clear for a file suffix, the dir should be easy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
合并工具可以使用任何可执行文件。要设置始终用
$other
覆盖$base
的合并工具,您可以使用以下方法:在 Windows 上使用此策略时,存在一个问题。您不能简单地将
替换为copy
shell 命令。由于某种原因,Mercurial 无法在此上下文中找到 shell 命令。我还没有在 *nix 上尝试过这个。要解决此问题,您可以创建一个分发执行复制的批处理文件。它只需要运行:
copy %1 %2
。一旦放置在您的 PATH 中,您就可以设置clobbermerge.executable=clobber.bat
。如果您安装了 kdiff3(Windows 上的 TortoiseHg 附带),则无需使用外部批处理文件,使用如下配置即可获得相同的结果:
配置的关键是 args 字段:
$base $other $other
:告诉kdiff3只使用$other
$output
:告诉 kdiff3 输出文件的名称Merge tools can use any executable file. To set up a merge tool which always overwrites
$base
with$other
, you can use the following:When using this strategy on Windows, there is one problem. You cannot simply replace
<copy executable>
with thecopy
shell command. For some reason, Mercurial fails to find shell commands in this context. I have not tried this on *nix.To work around this problem, you can create a distribute a batch file that performs the copy. It simply needs to run:
copy %1 %2
. Once placed on your PATH, you can setclobbermerge.executable=clobber.bat
.If you have kdiff3 installed (comes with TortoiseHg on Windows), you can get the same results without the external batch file using a configuration like this:
The key to this configuration is the
args
field:--auto
: tells kdiff3 not to open the GUI if there are no conflicts$base $other $other
: tells kdiff3 to only use$other
$output
: tells kdiff3 the name of the output file根据此 Mercurial MergeToolConfiguration 页面,您应该将
interal:other< /code> 直接在匹配模式之后:
According to this Mercurial MergeToolConfiguration page, you should put the
interal:other
directly after the match pattern: