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

login
register
mail settings
Submitter phabricator
Date March 21, 2018, 6:11 p.m.
Message ID <differential-rev-PHID-DREV-5ykn7xofc52qb2gc5z7q-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/29706/
State Superseded
Headers show

Comments

phabricator - March 21, 2018, 6:11 p.m.
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




To: martinvonz, phillco, #hg-reviewers
Cc: mercurial-devel
phabricator - March 21, 2018, 11:38 p.m.
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  Yeah, the old behavior was wonky. FWIW https://phab.mercurial-scm.org/rHG6cd9b8428104ed62b4fd477d618361f298b34865 and https://phab.mercurial-scm.org/rHGa69a77a80900eabe1257c935818d0910217e9702 seem relevant.

REPOSITORY
  rHG Mercurial

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

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

Patch

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}