changeset 33569:d341677d667d

rebase: add config to move rebase into a single transaction This was previously landed as cf8ad0e6c0e4 but backed out in a5abaa81fa because it broke hook mid rebase and caused conflict resolution data loss in the event of unexpected exceptions. This new version adds the behavior back but behind a config flag, since the performance improvement is notable in large repositories. The next patch adds a test covering this config. The old commit message was: 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. (grafted from cca36c7f35261b0e31beb226bf361067ef0e06ab) (grafted from dc497d8705b71503e32e07bd33925c1e42cf9c9a) Differential Revision: https://phab.mercurial-scm.org/D134
author Durham Goode <durham@fb.com>
date Tue, 18 Jul 2017 07:47:28 -0700
parents a2c35146596b
children e470f12d7d05
files hgext/rebase.py
diffstat 1 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Mon Jul 17 16:32:10 2017 -0700
+++ b/hgext/rebase.py	Tue Jul 18 07:47:28 2017 -0700
@@ -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
@@ -394,7 +394,7 @@
                                              self.state,
                                              self.destancestors,
                                              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')
@@ -641,6 +641,15 @@
       [commands]
       rebase.requiredest = True
 
+    By default, rebase will close the transaction after each commit. For
+    performance purposes, you can configure rebase to use a single transaction
+    across the entire rebase. WARNING: This setting introduces a significant
+    risk of losing the work you've done in a rebase if the rebase aborts
+    unexpectedly::
+
+      [rebase]
+      singletransaction = True
+
     Return Values:
 
     Returns 0 on success, 1 if nothing to rebase or there are
@@ -700,7 +709,12 @@
             if retcode is not None:
                 return retcode
 
-        rbsrt._performrebase()
+        tr = None
+        if ui.configbool('rebase', 'singletransaction'):
+            tr = repo.transaction('rebase')
+        with util.acceptintervention(tr):
+            rbsrt._performrebase(tr)
+
         rbsrt._finishrebase()
 
 def _definesets(ui, repo, destf=None, srcf=None, basef=None, revf=None,