This is an archive of the discontinued Mercurial Phabricator instance.

rebase: add config to move rebase into a single transaction
ClosedPublic

Authored by durham on Jul 18 2017, 11:09 AM.

Details

Summary

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)

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

durham created this revision.Jul 18 2017, 11:09 AM
martinvonz added inline comments.
hgext/rebase.py
712–718

acceptintervention() also accepts None (it's a little unexpected, I know, but also convenient), so this can probably be:

tr = None
if singletr:
    tr = repo.transaction('rebase')  
with util.acceptintervention(tr):
    rbsrt._performrebase(tr)

Also get rid of nullcontextmanager() then of course

durham updated this revision to Diff 273.Jul 18 2017, 2:14 PM
durham marked an inline comment as done.Jul 18 2017, 2:15 PM
martinvonz accepted this revision.Jul 18 2017, 4:42 PM
This revision is now accepted and ready to land.Jul 18 2017, 4:42 PM
This revision was automatically updated to reflect the committed changes.