rebase: pass in "keepbranch" to conclude[memory]node()
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 20 Mar 2018 21:49:09 -0700
changeset 37038 7db86856f27f
parent 37037 bd0086bd3af4
child 37039 7616073a4cf1
rebase: pass in "keepbranch" to conclude[memory]node() Both functions calculated the same "keepbranch" value from the "keepbranches" we passed in, so let's make the caller do it instead. Differential Revision: https://phab.mercurial-scm.org/D2919
hgext/rebase.py
--- a/hgext/rebase.py	Tue Mar 20 21:45:48 2018 -0700
+++ b/hgext/rebase.py	Tue Mar 20 21:49:09 2018 -0700
@@ -449,13 +449,14 @@
         extra = {'rebase_source': ctx.hex()}
         for c in self.extrafns:
             c(ctx, extra)
+        keepbranch = self.keepbranchesf and repo[p1].branch() != ctx.branch()
         if self.inmemory:
             newnode = concludememorynode(repo, ctx, p1, p2,
                 wctx=self.wctx,
                 extra=extra,
                 commitmsg=commitmsg,
                 editor=editor,
-                keepbranches=self.keepbranchesf,
+                keepbranch=keepbranch,
                 date=self.date)
             mergemod.mergestate.clean(repo)
         else:
@@ -463,7 +464,7 @@
                 extra=extra,
                 commitmsg=commitmsg,
                 editor=editor,
-                keepbranches=self.keepbranchesf,
+                keepbranch=keepbranch,
                 date=self.date)
 
         if newnode is None:
@@ -1023,13 +1024,11 @@
                      (max(destancestors),
                       ', '.join("%d" % p for p in sorted(parents))))
 
-def concludememorynode(repo, ctx, p1, p2, wctx, editor, extra, keepbranches,
+def concludememorynode(repo, ctx, p1, p2, wctx, editor, extra, keepbranch,
                        date, commitmsg):
     '''Commit the memory changes with parents p1 and p2. Reuse commit info from
     ctx.
     Return node of committed revision.'''
-    keepbranch = keepbranches and repo[p1].branch() != ctx.branch()
-
     destphase = max(ctx.phase(), phases.draft)
     overrides = {('phases', 'new-commit'): destphase}
     if keepbranch:
@@ -1054,7 +1053,7 @@
         wctx.clean() # Might be reused
         return commitres
 
-def concludenode(repo, ctx, p1, p2, editor, extra, keepbranches, date,
+def concludenode(repo, ctx, p1, p2, editor, extra, keepbranch, date,
                  commitmsg):
     '''Commit the wd changes with parents p1 and p2. Reuse commit info from ctx.
     Return node of committed revision.'''
@@ -1063,7 +1062,6 @@
         dsguard = dirstateguard.dirstateguard(repo, 'rebase')
     with dsguard:
         repo.setparents(repo[p1].node(), repo[p2].node())
-        keepbranch = keepbranches and repo[p1].branch() != ctx.branch()
 
         destphase = max(ctx.phase(), phases.draft)
         overrides = {('phases', 'new-commit'): destphase}