[Differential] [Request, 40 lines] D62: rebase: add config to move rebase into a single transaction
durham (Durham Goode)
phabricator at mercurial-scm.org
Wed Jul 12 17:56:15 UTC 2017
durham created this revision.
Herald added a subscriber: mercurial-devel.
REVISION SUMMARY
This was previously landed as https://phab.mercurial-scm.org/rHGcf8ad0e6c0e4555809c8e7232c8819ecf152bf1b but backed out in https://phab.mercurial-scm.org/rHGa5abaa81fad665602821b939ca4101d48f4d0ef7 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.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D62
AFFECTED FILES
hgext/rebase.py
mercurial/util.py
CHANGE DETAILS
Index: mercurial/util.py
===================================================================
--- mercurial/util.py
+++ mercurial/util.py
@@ -589,6 +589,20 @@
del self[key]
super(sortdict, self).__setitem__(key, value)
+class nullcontextmanager(object):
+ """A no-op context manager.
+ """
+ def __enter__(self):
+ return self
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ pass
+ def close(self):
+ pass
+ def release(self):
+ pass
+ def abort(self):
+ pass
+
class _lrucachenode(object):
"""A node in a doubly linked list.
Index: hgext/rebase.py
===================================================================
--- hgext/rebase.py
+++ hgext/rebase.py
@@ -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,18 @@
if retcode is not None:
return retcode
- rbsrt._performrebase()
+ singletr = ui.configbool('rebase', 'singletransaction')
+ if singletr:
+ tr = repo.transaction('rebase')
+ else:
+ tr = util.nullcontextmanager()
+ with tr:
+ try:
+ rbsrt._performrebase(tr if singletr else None)
+ except error.InterventionRequired:
+ tr.close()
+ raise
+
rbsrt._finishrebase()
def _definesets(ui, repo, destf=None, srcf=None, basef=None, revf=None,
EMAIL PREFERENCES
https://phab.mercurial-scm.org/settings/panel/emailpreferences/
To: durham
Cc: mercurial-devel, indygreg
More information about the Mercurial-devel
mailing list