D1576: amend: extract function for calculating changeset extras

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Sat Dec 2 03:12:17 UTC 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd3bba59a70e1: amend: extract function for calculating changeset extras (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1576?vs=4066&id=4080

REVISION DETAIL
  https://phab.mercurial-scm.org/D1576

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

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()



To: martinvonz, #hg-reviewers, yuja
Cc: mercurial-devel


More information about the Mercurial-devel mailing list