Excluding a file while merging in Mercurial

旧巷老猫 提交于 2019-12-03 20:30:11

问题


I use Mercurial with TortoiseHg. I have two branches (A and B) with two files (toto.cs and titi.cs).

Is there a way, when I want to merge B with A, to exclude titi.cs from merging, and only merge toto.cs? If it's possible, how can I do that?


回答1:


Sure. Not merging titi.cs is really just using titi.cs exactly as it exists in A or in B (your choice). You could do that manually like this:

hg update A
hg merge B
hg revert --rev A titi.cs

(swap A and B to go the other direction).
Or you could do that automatically in your Merge Tool Confguration with something like this in your .hgrc.

[merge-patterns]
titi.cs = internal:local

Which tells Mercurial to always use "this one not that one" for files matching that pattern.




回答2:


If you're talking about a certain file which you want to be exempt from merging, then see @Ry4chan's answer. This is perfectly valid: some files, like build-relating configs, can be autogenerated, and conflict resolution for them is useless. Or, you might actually want to drop changes made in a source file.

If, on the other hand, you are trying to mimic file- or directory-limited merges of SVN-like systems, be careful. The revert trick does not mean you merged some files and didn't merge other: you merged everything, the revert was just a kind of merge.

If you want to move some changes from one branch to another (say, backport a fix in a certain subsystem to an old stable branch), you don't merge the files with the fix; instead, you merge the changesets containing the fix; hg graft will help you do so.



来源:https://stackoverflow.com/questions/10879180/excluding-a-file-while-merging-in-mercurial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!