changeset 37034:fbc82a08bdcb

rebase: pass in ctx, not rev, to conclude[memory]node() 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. Differential Revision: https://phab.mercurial-scm.org/D2915
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 21 Mar 2018 11:04:13 -0700
parents 5f99142f59cc
children b7f5d03e1e54
files hgext/rebase.py
diffstat 1 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Wed Mar 21 11:03:31 2018 -0700
+++ b/hgext/rebase.py	Wed Mar 21 11:04:13 2018 -0700
@@ -454,8 +454,9 @@
         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,
@@ -464,7 +465,7 @@
                 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,9 +1065,9 @@
         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()
@@ -1075,7 +1075,6 @@
         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()