Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 52989:688665425496
diff: add a --ignore-changes-from-ancestors option
This is a generalisation of the new feature from evolve but for any diff, it
allow to compares changes to patches regardless of the changes introduced by
ancestors, this is typically useful after rebase and graft.
I am not very happy about the name, but it is still experimental, so that can
be improved later.
Having the ability to compare ranges of commit would probably be handy too, but
this changeset focus in getting the basic case in. We have to think about the
UI a bit ahead however.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 03 Feb 2023 11:01:23 +0100 |
parents | 25b344f2aeef |
children |
line wrap: on
line diff
--- a/mercurial/commands.py Tue Feb 18 15:33:51 2025 +0100 +++ b/mercurial/commands.py Fri Feb 03 11:01:23 2023 +0100 @@ -27,6 +27,7 @@ bundlecaches, changegroup, cmdutil, + context as contextmod, copies, debugcommands as debugcommandsmod, destutil, @@ -2540,6 +2541,14 @@ (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'ignore-changes-from-ancestors', + False, + _( + b'only compare the change made by the selected revision (EXPERIMENTAL)' + ), + ), ] + diffopts + diffopts2 @@ -2621,6 +2630,7 @@ to_rev = opts.get(b'to') stat = opts.get(b'stat') reverse = opts.get(b'reverse') + patch_only = opts.get(b'ignore_changes_from_ancestors') cmdutil.check_incompatible_arguments(opts, b'from', [b'rev', b'change']) cmdutil.check_incompatible_arguments(opts, b'to', [b'rev', b'change']) @@ -2638,6 +2648,30 @@ repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn') ctx1, ctx2 = logcmdutil.revpair(repo, revs) + if patch_only and ctx1.p1() != ctx2.p1(): + old_base = ctx1.p1() + new_base = ctx2.p1() + new_ctx = contextmod.overlayworkingctx(repo) + new_ctx.setbase(ctx1) + configoverrides = { + (b'ui', b'forcemerge'): b'internal:merge3-lie-about-conflicts' + } + with ui.configoverride(configoverrides, b'obslog-diff'), ui.silent(): + mergemod._update( + repo, + new_base, + labels=[ + b'from', + b'parent-of-to', + b'parent-of-from', + ], + force=True, + branchmerge=True, + wc=new_ctx, + ancestor=old_base, + ) + ctx1 = new_ctx.tomemctx(text=ctx1.description()) + if reverse: ctxleft = ctx2 ctxright = ctx1