Patchwork D2915: rebase: pass in ctx, not rev, to conclude[memory]node()

login
register
mail settings
Submitter phabricator
Date March 21, 2018, 6:11 p.m.
Message ID <differential-rev-PHID-DREV-tawpzch6ma7fwempjxdq-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/29702/
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
  They both need it and there's no locking that might make the results
  different, so let's do it in one place. This also lets us move out
  more common code in the following patches.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS




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

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -454,17 +454,18 @@ 
         Reuse commit info from rev but also store useful information in extra.
         Return node of committed revision.'''
         repo = self.repo
+        ctx = repo[rev]
         if self.inmemory:
-            newnode = concludememorynode(repo, rev, p1, p2,
+            newnode = concludememorynode(repo, ctx, p1, p2,
                 wctx=self.wctx,
                 extrafn=_makeextrafn(self.extrafns),
                 commitmsg=commitmsg,
                 editor=editor,
                 keepbranches=self.keepbranchesf,
                 date=self.date)
             mergemod.mergestate.clean(repo)
         else:
-            newnode = concludenode(repo, rev, p1, p2,
+            newnode = concludenode(repo, ctx, p1, p2,
                 extrafn=_makeextrafn(self.extrafns),
                 commitmsg=commitmsg,
                 editor=editor,
@@ -1028,12 +1029,11 @@ 
                      (max(destancestors),
                       ', '.join("%d" % p for p in sorted(parents))))
 
-def concludememorynode(repo, rev, p1, p2, wctx, editor, extrafn, keepbranches,
+def concludememorynode(repo, ctx, p1, p2, wctx, editor, extrafn, keepbranches,
                        date, commitmsg=None):
     '''Commit the memory changes with parents p1 and p2. Reuse commit info from
-    rev but also store useful information in extra.
+    ctx but also store useful information in extra.
     Return node of committed revision.'''
-    ctx = repo[rev]
     if commitmsg is None:
         commitmsg = ctx.description()
     keepbranch = keepbranches and repo[p1].branch() != ctx.branch()
@@ -1065,17 +1065,16 @@ 
         wctx.clean() # Might be reused
         return commitres
 
-def concludenode(repo, rev, p1, p2, editor, extrafn, keepbranches, date,
+def concludenode(repo, ctx, p1, p2, editor, extrafn, keepbranches, date,
                  commitmsg=None):
-    '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev
+    '''Commit the wd changes with parents p1 and p2. Reuse commit info from ctx
     but also store useful information in extra.
     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())
-        ctx = repo[rev]
         if commitmsg is None:
             commitmsg = ctx.description()
         keepbranch = keepbranches and repo[p1].branch() != ctx.branch()