diff hgext/rebase.py @ 31226:cf8ad0e6c0e4

rebase: move actual rebase into a single transaction Previously, rebasing would open several transaction over the course of rebasing several commits. Opening a transaction can have notable overhead (like copying the dirstate) which can add up when rebasing many commits. This patch adds a single large transaction around the actual commit rebase operation, with a catch for intervention which serializes the current state if we need to drop back to the terminal for user intervention. Amazingly, almost all the tests seem to pass. On large repos with large working copies, this can speed up rebasing 7 commits by 25%. I'd expect the percentage to be a bit larger for rebasing even more commits. There are minor test changes because we're rolling back the entire transaction during unexpected exceptions instead of just stopping mid-rebase, so there's no more backup bundle. It also leave an unknown file in the working copy, since our clean up 'hg update' doesn't delete unknown files.
author Durham Goode <durham@fb.com>
date Tue, 07 Mar 2017 16:27:32 -0800
parents 749b057b01f3
children 98658f73588a
line wrap: on
line diff
--- a/hgext/rebase.py	Tue Mar 07 16:30:31 2017 -0800
+++ b/hgext/rebase.py	Tue Mar 07 16:27:32 2017 -0800
@@ -343,7 +343,7 @@
         if dest.closesbranch() and not self.keepbranchesf:
             self.ui.status(_('reopening closed branch head %s\n') % dest)
 
-    def _performrebase(self):
+    def _performrebase(self, tr):
         repo, ui, opts = self.repo, self.ui, self.opts
         if self.keepbranchesf:
             # insert _savebranch at the start of extrafns so if
@@ -393,7 +393,7 @@
                                              self.state,
                                              self.targetancestors,
                                              self.obsoletenotrebased)
-                self.storestatus()
+                self.storestatus(tr=tr)
                 storecollapsemsg(repo, self.collapsemsg)
                 if len(repo[None].parents()) == 2:
                     repo.ui.debug('resuming interrupted rebase\n')
@@ -711,7 +711,12 @@
             if retcode is not None:
                 return retcode
 
-        rbsrt._performrebase()
+        with repo.transaction('rebase') as tr:
+            try:
+                rbsrt._performrebase(tr)
+            except error.InterventionRequired:
+                tr.close()
+                raise
         rbsrt._finishrebase()
     finally:
         release(lock, wlock)