Mercurial > hg
comparison hgext/rebase.py @ 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 | 8bfd10e4c55a |
children | 52f82e7d6a7e |
comparison
equal
deleted
inserted
replaced
33568:a2c35146596b | 33569:d341677d667d |
---|---|
341 self.destancestors) | 341 self.destancestors) |
342 | 342 |
343 if dest.closesbranch() and not self.keepbranchesf: | 343 if dest.closesbranch() and not self.keepbranchesf: |
344 self.ui.status(_('reopening closed branch head %s\n') % dest) | 344 self.ui.status(_('reopening closed branch head %s\n') % dest) |
345 | 345 |
346 def _performrebase(self): | 346 def _performrebase(self, tr): |
347 repo, ui, opts = self.repo, self.ui, self.opts | 347 repo, ui, opts = self.repo, self.ui, self.opts |
348 if self.keepbranchesf: | 348 if self.keepbranchesf: |
349 # insert _savebranch at the start of extrafns so if | 349 # insert _savebranch at the start of extrafns so if |
350 # there's a user-provided extrafn it can clobber branch if | 350 # there's a user-provided extrafn it can clobber branch if |
351 # desired | 351 # desired |
392 _('changesets'), total) | 392 _('changesets'), total) |
393 p1, p2, base = defineparents(repo, rev, self.dest, | 393 p1, p2, base = defineparents(repo, rev, self.dest, |
394 self.state, | 394 self.state, |
395 self.destancestors, | 395 self.destancestors, |
396 self.obsoletenotrebased) | 396 self.obsoletenotrebased) |
397 self.storestatus() | 397 self.storestatus(tr=tr) |
398 storecollapsemsg(repo, self.collapsemsg) | 398 storecollapsemsg(repo, self.collapsemsg) |
399 if len(repo[None].parents()) == 2: | 399 if len(repo[None].parents()) == 2: |
400 repo.ui.debug('resuming interrupted rebase\n') | 400 repo.ui.debug('resuming interrupted rebase\n') |
401 else: | 401 else: |
402 try: | 402 try: |
639 option:: | 639 option:: |
640 | 640 |
641 [commands] | 641 [commands] |
642 rebase.requiredest = True | 642 rebase.requiredest = True |
643 | 643 |
644 By default, rebase will close the transaction after each commit. For | |
645 performance purposes, you can configure rebase to use a single transaction | |
646 across the entire rebase. WARNING: This setting introduces a significant | |
647 risk of losing the work you've done in a rebase if the rebase aborts | |
648 unexpectedly:: | |
649 | |
650 [rebase] | |
651 singletransaction = True | |
652 | |
644 Return Values: | 653 Return Values: |
645 | 654 |
646 Returns 0 on success, 1 if nothing to rebase or there are | 655 Returns 0 on success, 1 if nothing to rebase or there are |
647 unresolved conflicts. | 656 unresolved conflicts. |
648 | 657 |
698 destspace=destspace) | 707 destspace=destspace) |
699 retcode = rbsrt._preparenewrebase(dest, rebaseset) | 708 retcode = rbsrt._preparenewrebase(dest, rebaseset) |
700 if retcode is not None: | 709 if retcode is not None: |
701 return retcode | 710 return retcode |
702 | 711 |
703 rbsrt._performrebase() | 712 tr = None |
713 if ui.configbool('rebase', 'singletransaction'): | |
714 tr = repo.transaction('rebase') | |
715 with util.acceptintervention(tr): | |
716 rbsrt._performrebase(tr) | |
717 | |
704 rbsrt._finishrebase() | 718 rbsrt._finishrebase() |
705 | 719 |
706 def _definesets(ui, repo, destf=None, srcf=None, basef=None, revf=None, | 720 def _definesets(ui, repo, destf=None, srcf=None, basef=None, revf=None, |
707 destspace=None): | 721 destspace=None): |
708 """use revisions argument to define destination and rebase set | 722 """use revisions argument to define destination and rebase set |