简体   繁体   中英

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.

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.

In mercurial if you merge or resolve with the :merge3 tool, it will leave markers in the files for any conflicts. The fileset unresolved() contains only the files with conflicts. Using perl to print just the filenames and the unresolved sections (ignoring the cleanly merged sections):

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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