Patchwork D2921: rebase: move config override out of conclude[memory]node()

login
register
mail settings
Submitter phabricator
Date March 21, 2018, 6:11 p.m.
Message ID <differential-rev-PHID-DREV-ohbx63lm3idxmlvq4kkb-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/29709/
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.

REPOSITORY
  rHG Mercurial

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

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,29 +454,28 @@ 
         overrides = {('phases', 'new-commit'): destphase}
         if keepbranch:
             overrides[('ui', 'allowemptycommit')] = True
-        if self.inmemory:
-            newnode = concludememorynode(repo, ctx, p1, p2,
-                wctx=self.wctx,
-                extra=extra,
-                commitmsg=commitmsg,
-                editor=editor,
-                overrides=overrides,
-                date=self.date)
-            mergemod.mergestate.clean(repo)
-        else:
-            newnode = concludenode(repo, ctx, p1, p2,
-                extra=extra,
-                commitmsg=commitmsg,
-                editor=editor,
-                overrides=overrides,
-                date=self.date)
+        with repo.ui.configoverride(overrides, 'rebase'):
+            if self.inmemory:
+                newnode = concludememorynode(repo, ctx, p1, p2,
+                    wctx=self.wctx,
+                    extra=extra,
+                    commitmsg=commitmsg,
+                    editor=editor,
+                    date=self.date)
+                mergemod.mergestate.clean(repo)
+            else:
+                newnode = concludenode(repo, ctx, p1, p2,
+                    extra=extra,
+                    commitmsg=commitmsg,
+                    editor=editor,
+                    date=self.date)
 
-        if newnode is None:
-            # If it ended up being a no-op commit, then the normal
-            # merge state clean-up path doesn't happen, so do it
-            # here. Fix issue5494
-            mergemod.mergestate.clean(repo)
-        return newnode
+            if newnode is None:
+                # If it ended up being a no-op commit, then the normal
+                # merge state clean-up path doesn't happen, so do it
+                # here. Fix issue5494
+                mergemod.mergestate.clean(repo)
+            return newnode
 
     def _rebasenode(self, tr, rev, allowdivergence, progressfn):
         repo, ui, opts = self.repo, self.ui, self.opts
@@ -1028,47 +1027,43 @@ 
                      (max(destancestors),
                       ', '.join("%d" % p for p in sorted(parents))))
 
-def concludememorynode(repo, ctx, p1, p2, wctx, editor, extra, overrides, date,
-                       commitmsg):
+def concludememorynode(repo, ctx, p1, p2, wctx, editor, extra, date, commitmsg):
     '''Commit the memory changes with parents p1 and p2. Reuse commit info from
     ctx.
     Return node of committed revision.'''
-    with repo.ui.configoverride(overrides, 'rebase'):
-        # Replicates the empty check in ``repo.commit``.
-        if wctx.isempty() and not repo.ui.configbool('ui', 'allowemptycommit'):
-            return None
+    # Replicates the empty check in ``repo.commit``.
+    if wctx.isempty() and not repo.ui.configbool('ui', 'allowemptycommit'):
+        return None
 
-        if date is None:
-            date = ctx.date()
+    if date is None:
+        date = ctx.date()
 
-        # By convention, ``extra['branch']`` (set by extrafn) clobbers
-        # ``branch`` (used when passing ``--keepbranches``).
-        branch = repo[p1].branch()
-        if 'branch' in extra:
-            branch = extra['branch']
+    # By convention, ``extra['branch']`` (set by extrafn) clobbers
+    # ``branch`` (used when passing ``--keepbranches``).
+    branch = repo[p1].branch()
+    if 'branch' in extra:
+        branch = extra['branch']
 
-        memctx = wctx.tomemctx(commitmsg, parents=(p1, p2), date=date,
-            extra=extra, user=ctx.user(), branch=branch, editor=editor)
-        commitres = repo.commitctx(memctx)
-        wctx.clean() # Might be reused
-        return commitres
+    memctx = wctx.tomemctx(commitmsg, parents=(p1, p2), date=date,
+        extra=extra, user=ctx.user(), branch=branch, editor=editor)
+    commitres = repo.commitctx(memctx)
+    wctx.clean() # Might be reused
+    return commitres
 
-def concludenode(repo, ctx, p1, p2, editor, extra, overrides, date,
-                 commitmsg):
+def concludenode(repo, ctx, p1, p2, editor, extra, date, commitmsg):
     '''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())
 
-        with repo.ui.configoverride(overrides, 'rebase'):
-            # Commit might fail if unresolved files exist
-            if date is None:
-                date = ctx.date()
-            newnode = repo.commit(text=commitmsg, user=ctx.user(),
-                                  date=date, extra=extra, editor=editor)
+        # Commit might fail if unresolved files exist
+        if date is None:
+            date = ctx.date()
+        newnode = repo.commit(text=commitmsg, user=ctx.user(),
+                              date=date, extra=extra, editor=editor)
 
         repo.dirstate.setbranch(repo[newnode].branch())
         return newnode