D2917: rebase: pass in "extra" itself into conclude[memory]node()

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Wed Mar 21 18:11:19 UTC 2018


martinvonz created this revision.
martinvonz added a reviewer: phillco.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We were passing in a function instead for no clear reason (probably
  historical, but I haven't bothered looking).

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -457,18 +457,22 @@
         ctx = repo[rev]
         if commitmsg is None:
             commitmsg = ctx.description()
+        extrafn = _makeextrafn(self.extrafns)
+        extra = {'rebase_source': ctx.hex()}
+        if extrafn:
+            extrafn(ctx, extra)
         if self.inmemory:
             newnode = concludememorynode(repo, ctx, p1, p2,
                 wctx=self.wctx,
-                extrafn=_makeextrafn(self.extrafns),
+                extra=extra,
                 commitmsg=commitmsg,
                 editor=editor,
                 keepbranches=self.keepbranchesf,
                 date=self.date)
             mergemod.mergestate.clean(repo)
         else:
             newnode = concludenode(repo, ctx, p1, p2,
-                extrafn=_makeextrafn(self.extrafns),
+                extra=extra,
                 commitmsg=commitmsg,
                 editor=editor,
                 keepbranches=self.keepbranchesf,
@@ -1031,15 +1035,12 @@
                      (max(destancestors),
                       ', '.join("%d" % p for p in sorted(parents))))
 
-def concludememorynode(repo, ctx, p1, p2, wctx, editor, extrafn, keepbranches,
+def concludememorynode(repo, ctx, p1, p2, wctx, editor, extra, keepbranches,
                        date, commitmsg):
     '''Commit the memory changes with parents p1 and p2. Reuse commit info from
-    ctx but also store useful information in extra.
+    ctx.
     Return node of committed revision.'''
     keepbranch = keepbranches and repo[p1].branch() != ctx.branch()
-    extra = {'rebase_source': ctx.hex()}
-    if extrafn:
-        extrafn(ctx, extra)
 
     destphase = max(ctx.phase(), phases.draft)
     overrides = {('phases', 'new-commit'): destphase}
@@ -1065,20 +1066,16 @@
         wctx.clean() # Might be reused
         return commitres
 
-def concludenode(repo, ctx, p1, p2, editor, extrafn, keepbranches, date,
+def concludenode(repo, ctx, p1, p2, editor, extra, keepbranches, date,
                  commitmsg):
-    '''Commit the wd changes with parents p1 and p2. Reuse commit info from ctx
-    but also store useful information in extra.
+    '''Commit the wd changes with parents p1 and p2. Reuse commit info from ctx.
     Return node of committed revision.'''
     dsguard = util.nullcontextmanager()
     if not repo.ui.configbool('rebase', 'singletransaction'):
         dsguard = dirstateguard.dirstateguard(repo, 'rebase')
     with dsguard:
         repo.setparents(repo[p1].node(), repo[p2].node())
         keepbranch = keepbranches and repo[p1].branch() != ctx.branch()
-        extra = {'rebase_source': ctx.hex()}
-        if extrafn:
-            extrafn(ctx, extra)
 
         destphase = max(ctx.phase(), phases.draft)
         overrides = {('phases', 'new-commit'): destphase}



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


More information about the Mercurial-devel mailing list