diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -3114,6 +3114,22 @@ else: return f not in ctx2.manifest() +def _amendextras(extra, old, wctx): + """Calculated extras for amended changeset. + + This is a separate function so extensions can override it and filter out + (or add) certain entries. + """ + # Copy to avoid mutating input + extra = extra.copy() + # Update extra dict from amended commit (e.g. to preserve graft + # source) + extra.update(old.extra()) + + # Also update it from the from the wctx + extra.update(wctx.extra()) + return extra + def amend(ui, repo, old, extra, pats, opts): # avoid cycle context -> subrepo -> cmdutil from . import context @@ -3137,14 +3153,7 @@ # base o - first parent of the changeset to amend wctx = repo[None] - # Copy to avoid mutating input - extra = extra.copy() - # Update extra dict from amended commit (e.g. to preserve graft - # source) - extra.update(old.extra()) - - # Also update it from the from the wctx - extra.update(wctx.extra()) + extra = _amendextras(extra, old, wctx) user = opts.get('user') or old.user() date = opts.get('date') or old.date()