rebase: don't take out a dirstate guard for in-memory rebase
authorPhil Cohen <phillco@fb.com>
Fri, 22 Dec 2017 00:44:36 -0600
changeset 35484 01b084914a60
parent 35483 8d05705bde0a
child 35485 964510dcdc2a
rebase: don't take out a dirstate guard for in-memory rebase Since IMM doesn't affect the dirstate, it's not needed, and might be faster. Differential Revision: https://phab.mercurial-scm.org/D1745
hgext/rebase.py
--- a/hgext/rebase.py	Fri Dec 22 02:38:08 2017 -0500
+++ b/hgext/rebase.py	Fri Dec 22 00:44:36 2017 -0600
@@ -567,8 +567,6 @@
             revtoreuse = max(self.state)
 
             dsguard = None
-            if ui.configbool('rebase', 'singletransaction'):
-                dsguard = dirstateguard.dirstateguard(repo, 'rebase')
             if self.inmemory:
                 newnode = concludememorynode(repo, revtoreuse, p1,
                     self.external,
@@ -578,6 +576,8 @@
                     keepbranches=self.keepbranchesf,
                     date=self.date, wctx=self.wctx)
             else:
+                if ui.configbool('rebase', 'singletransaction'):
+                    dsguard = dirstateguard.dirstateguard(repo, 'rebase')
                 with util.acceptintervention(dsguard):
                     newnode = concludenode(repo, revtoreuse, p1, self.external,
                         commitmsg=commitmsg,
@@ -851,8 +851,14 @@
         singletr = ui.configbool('rebase', 'singletransaction')
         if singletr:
             tr = repo.transaction('rebase')
+
+        # If `rebase.singletransaction` is enabled, wrap the entire operation in
+        # one transaction here. Otherwise, transactions are obtained when
+        # committing each node, which is slower but allows partial success.
         with util.acceptintervention(tr):
-            if singletr:
+            # Same logic for the dirstate guard, except we don't create one when
+            # rebasing in-memory (it's not needed).
+            if singletr and not inmemory:
                 dsguard = dirstateguard.dirstateguard(repo, 'rebase')
             with util.acceptintervention(dsguard):
                 rbsrt._performrebase(tr)
@@ -1032,8 +1038,8 @@
 def concludememorynode(repo, rev, p1, p2, wctx=None,
                        commitmsg=None, editor=None, extrafn=None,
                        keepbranches=False, date=None):
-    '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev
-    but also store useful information in extra.
+    '''Commit the memory changes with parents p1 and p2. Reuse commit info from
+    rev but also store useful information in extra.
     Return node of committed revision.'''
     ctx = repo[rev]
     if commitmsg is None: