Patchwork D1576: amend: extract function for calculating changeset extras

login
register
mail settings
Submitter phabricator
Date Dec. 2, 2017, 3:12 a.m.
Message ID <a077d0d25cd05a25494864de90bc6d47@localhost.localdomain>
Download mbox | patch
Permalink /patch/25887/
State Not Applicable
Headers show

Comments

phabricator - Dec. 2, 2017, 3:12 a.m.
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




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

Patch

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