Mercurial > hg
comparison hgext/rebase.py @ 37032:98663bed146e
rebase: store rebase state after each commit
Before this patch, we stored the rebase state early in the processing
of a node, before we updated the rebase state to indicate that the
node was processed. This meant that we could redo the working copy
merge and run into conflicts. However, this only happened in the
--collapse case if the rebase was interrupted while editing the final
commit message; in the case earlier interruptions, we would instead
detect the in-process revision by finding two dirstate parents.
This patch moves the writing of the rebase state to after we have
completed the revision completely, and, importantly, after we have
updated the rebase state to mark it done. This means we'll realize
that all nodes have been rebased in the case mentioned above of
editing the final commit message of a --collapse. See change to test
case.
I also moved the writing outside of the large if/elif block in
_rebasenode(). This shouldn't matter much, but seems cleaner. One
observable effect is if rebase was interrupted just after ignoring an
obsolete node ("not rebasing ####, already in destination"), we used
to come up with the same decision after --continue too, but after this
patch we'll instead say "already rebased ###". This seems more
consistent, since that's what we would do with obsolete nodes that had
been marked done earlier in the process (not only just before the
interruption).
Differential Revision: https://phab.mercurial-scm.org/D2913
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 21 Mar 2018 11:01:19 -0700 |
parents | 74f91bec6991 |
children | 5f99142f59cc |
comparison
equal
deleted
inserted
replaced
37031:74f91bec6991 | 37032:98663bed146e |
---|---|
482 ui.status(_('rebasing %s\n') % desc) | 482 ui.status(_('rebasing %s\n') % desc) |
483 progressfn(ctx) | 483 progressfn(ctx) |
484 p1, p2, base = defineparents(repo, rev, self.destmap, | 484 p1, p2, base = defineparents(repo, rev, self.destmap, |
485 self.state, self.skipped, | 485 self.state, self.skipped, |
486 self.obsoletenotrebased) | 486 self.obsoletenotrebased) |
487 if not tr: | |
488 self.storestatus() | |
489 if len(repo[None].parents()) == 2: | 487 if len(repo[None].parents()) == 2: |
490 repo.ui.debug('resuming interrupted rebase\n') | 488 repo.ui.debug('resuming interrupted rebase\n') |
491 else: | 489 else: |
492 overrides = {('ui', 'forcemerge'): opts.get('tool', '')} | 490 overrides = {('ui', 'forcemerge'): opts.get('tool', '')} |
493 with ui.configoverride(overrides, 'rebase'): | 491 with ui.configoverride(overrides, 'rebase'): |
544 self.state[rev] = p1 | 542 self.state[rev] = p1 |
545 ui.debug('next revision set to %d\n' % p1) | 543 ui.debug('next revision set to %d\n' % p1) |
546 else: | 544 else: |
547 ui.status(_('already rebased %s as %s\n') % | 545 ui.status(_('already rebased %s as %s\n') % |
548 (desc, repo[self.state[rev]])) | 546 (desc, repo[self.state[rev]])) |
547 if not tr: | |
548 # When not using single transaction, store state after each | |
549 # commit is completely done. On InterventionRequired, we thus | |
550 # won't store the status. Instead, we'll hit the "len(parents) == 2" | |
551 # case and realize that the commit was in progress. | |
552 self.storestatus() | |
549 | 553 |
550 def _finishrebase(self): | 554 def _finishrebase(self): |
551 repo, ui, opts = self.repo, self.ui, self.opts | 555 repo, ui, opts = self.repo, self.ui, self.opts |
552 fm = ui.formatter('rebase', opts) | 556 fm = ui.formatter('rebase', opts) |
553 fm.startitem() | 557 fm.startitem() |