Mercurial > hg
comparison hgext/rebase.py @ 37031:74f91bec6991
rebase: register status file generator only once when using single transaction
rebase.storestatus() behaved differently depending on whether a
transaction is passed to it. If a transaction is passed, it registers
a "file generator" that runs when the transaction commits. If no
transaction was passed, it writes the rebase state immediately. This
imprecise timing of the writing makes it hard to reason about, so
let's make it more explicit which behavior we're getting by checking
if we have a transaction before calling it. For the single-transaction
case, move the call to storestatus(tr) early and do it only once since
it's only going to write the file (at most) once anyway.
Differential Revision: https://phab.mercurial-scm.org/D2912
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 21 Mar 2018 10:46:00 -0700 |
parents | 36c4e25c3ce1 |
children | 98663bed146e |
comparison
equal
deleted
inserted
replaced
37030:9cc9b3e155f8 | 37031:74f91bec6991 |
---|---|
418 bookmarks.deactivate(repo) | 418 bookmarks.deactivate(repo) |
419 | 419 |
420 # Store the state before we begin so users can run 'hg rebase --abort' | 420 # Store the state before we begin so users can run 'hg rebase --abort' |
421 # if we fail before the transaction closes. | 421 # if we fail before the transaction closes. |
422 self.storestatus() | 422 self.storestatus() |
423 if tr: | |
424 # When using single transaction, store state when transaction | |
425 # commits. | |
426 self.storestatus(tr) | |
423 | 427 |
424 cands = [k for k, v in self.state.iteritems() if v == revtodo] | 428 cands = [k for k, v in self.state.iteritems() if v == revtodo] |
425 total = len(cands) | 429 total = len(cands) |
426 posholder = [0] | 430 posholder = [0] |
427 def progress(ctx): | 431 def progress(ctx): |
478 ui.status(_('rebasing %s\n') % desc) | 482 ui.status(_('rebasing %s\n') % desc) |
479 progressfn(ctx) | 483 progressfn(ctx) |
480 p1, p2, base = defineparents(repo, rev, self.destmap, | 484 p1, p2, base = defineparents(repo, rev, self.destmap, |
481 self.state, self.skipped, | 485 self.state, self.skipped, |
482 self.obsoletenotrebased) | 486 self.obsoletenotrebased) |
483 self.storestatus(tr=tr) | 487 if not tr: |
488 self.storestatus() | |
484 if len(repo[None].parents()) == 2: | 489 if len(repo[None].parents()) == 2: |
485 repo.ui.debug('resuming interrupted rebase\n') | 490 repo.ui.debug('resuming interrupted rebase\n') |
486 else: | 491 else: |
487 overrides = {('ui', 'forcemerge'): opts.get('tool', '')} | 492 overrides = {('ui', 'forcemerge'): opts.get('tool', '')} |
488 with ui.configoverride(overrides, 'rebase'): | 493 with ui.configoverride(overrides, 'rebase'): |