简体   繁体   English

我如何看待所有合并(在git合并)中的冲突?

[英]How can I see diffs of all of the conflicts in a mercurial (or git) merge?

This question asks how to see which files have conflicts in a merge. 这个问题问如何在合并中查看哪些文件有冲突。 I'd also like to be able to quickly see listings of the diffs for all of the conflicts (as opposed to the diffs in the merge that went through cleanly.) 我还希望能够快速查看所有冲突的差异列表(与干净进行的合并中的差异相反)。

For instance, this would make it possible to quickly dispense with some conflicts that are just "noise" by resolving those with --tool :other --tool :local or --tool :union without bringing up a merge editor. 例如,通过使用--tool :other --tool :local--tool :union解决这些冲突,而无需调出合并编辑器,就可以快速消除那些只是“噪音”的冲突。

I think answers (I'm formulating one right now) will be analogous with small differences for git and mercurial, so I'll risk leaving the question vc-agnostic. 我认为答案(我现在正在制定一个答案)与git和mercurial的细微差别类似,因此我冒着将vc不可知的风险。

In mercurial if you merge or resolve with the :merge3 tool, it will leave markers in the files for any conflicts. 通常,如果您使用:merge3工具合并或解析,它将在文件中保留标记以防冲突。 The fileset unresolved() contains only the files with conflicts. 文件集unresolved()仅包含有冲突的文件。 Using perl to print just the filenames and the unresolved sections (ignoring the cleanly merged sections): 使用perl仅打印文件名和未解析的部分(忽略干净合并的部分):

hg merge --tool :merge3 <branchtomerge>
hg diff 'set:unresolved()' | perl -ne 'print if m|^\+\+\+ | or m|<<<+ local$| .. m|>>>+ other$|'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM