Mercurial > public > mercurial-scm > hg
diff mercurial/commands.py @ 46448:1a7d12c82057
diff: add experimental support for "merge diffs"
The way this works is it re-runs the merge and "stores" conflicts, and then
diffs against the conflicted result. In a normal merge, you should only see
diffs against conflicted regions or in cases where there was a semantic
conflict but not a textual one. This makes it easier to detect "evil merges"
that contain substantial new work embedded in the merge commit.
Differential Revision: https://phab.mercurial-scm.org/D8504
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 07 May 2020 16:50:26 -0400 |
parents | 16c18d5e5dc8 |
children | 62a0b5daa15f |
line wrap: on
line diff
--- a/mercurial/commands.py Mon Feb 01 12:55:31 2021 +0100 +++ b/mercurial/commands.py Thu May 07 16:50:26 2020 -0400 @@ -29,6 +29,7 @@ bundlecaches, changegroup, cmdutil, + context as contextmod, copies, debugcommands as debugcommandsmod, destutil, @@ -2464,6 +2465,16 @@ (b'', b'from', b'', _(b'revision to diff from'), _(b'REV1')), (b'', b'to', b'', _(b'revision to diff to'), _(b'REV2')), (b'c', b'change', b'', _(b'change made by revision'), _(b'REV')), + ( + b'', + b'merge', + False, + _( + b'show difference between auto-merge and committed ' + b'merge for merge commits (EXPERIMENTAL)' + ), + _(b'REV'), + ), ] + diffopts + diffopts2 @@ -2544,13 +2555,31 @@ to_rev = opts.get(b'to') stat = opts.get(b'stat') reverse = opts.get(b'reverse') + diffmerge = opts.get(b'merge') cmdutil.check_incompatible_arguments(opts, b'from', [b'rev', b'change']) cmdutil.check_incompatible_arguments(opts, b'to', [b'rev', b'change']) if change: repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn') ctx2 = scmutil.revsingle(repo, change, None) - ctx1 = ctx2.p1() + if diffmerge and ctx2.p2().node() != nullid: + pctx1 = ctx2.p1() + pctx2 = ctx2.p2() + wctx = contextmod.overlayworkingctx(repo) + wctx.setbase(pctx1) + with ui.configoverride( + { + ( + b'ui', + b'forcemerge', + ): b'internal:merge3-lie-about-conflicts', + }, + b'diff --merge', + ): + mergemod.merge(pctx2, wc=wctx) + ctx1 = wctx + else: + ctx1 = ctx2.p1() elif from_rev or to_rev: repo = scmutil.unhidehashlikerevs( repo, [from_rev] + [to_rev], b'nowarn'