Mercurial > hg
comparison hgext/rebase.py @ 45555:feffeb18d412
rebase: teach in-memory rebase to not restart with on-disk rebase on conflict
When in-memory rebase runs into conflicts, it redoes the whole rebase
operation. This patch teaches it to instead discard just the current
`overlayworkingctx` and redo that node on disk.
I've tested this by enabling in-memory rebase by default and checking
that there are no unexpected differences after this patch.
The next step is to make it so that `hg rebase --continue` can use
in-memory merge.
Differential Revision: https://phab.mercurial-scm.org/D9076
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 18 Sep 2020 15:03:06 -0700 |
parents | e9468f14379a |
children | 03726f5b6092 |
comparison
equal
deleted
inserted
replaced
45554:abad925af2ef | 45555:feffeb18d412 |
---|---|
613 repo.ui.debug(b'resuming interrupted rebase\n') | 613 repo.ui.debug(b'resuming interrupted rebase\n') |
614 self.resume = False | 614 self.resume = False |
615 else: | 615 else: |
616 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')} | 616 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')} |
617 with ui.configoverride(overrides, b'rebase'): | 617 with ui.configoverride(overrides, b'rebase'): |
618 rebasenode( | 618 try: |
619 repo, rev, p1, p2, base, self.collapsef, wctx=self.wctx, | 619 rebasenode( |
620 ) | 620 repo, |
621 rev, | |
622 p1, | |
623 p2, | |
624 base, | |
625 self.collapsef, | |
626 wctx=self.wctx, | |
627 ) | |
628 except error.InMemoryMergeConflictsError: | |
629 if self.dryrun: | |
630 raise error.ConflictResolutionRequired(b'rebase') | |
631 if self.collapsef: | |
632 # TODO: Make the overlayworkingctx reflected | |
633 # in the working copy here instead of re-raising | |
634 # so the entire rebase operation is retried. | |
635 raise | |
636 ui.status( | |
637 _( | |
638 b"hit merge conflicts; rebasing that " | |
639 b"commit again in the working copy\n" | |
640 ) | |
641 ) | |
642 cmdutil.bailifchanged(repo) | |
643 self.inmemory = False | |
644 self._assignworkingcopy() | |
645 mergemod.update( | |
646 repo, | |
647 p1, | |
648 branchmerge=False, | |
649 force=False, | |
650 wc=self.wctx, | |
651 ) | |
652 rebasenode( | |
653 repo, | |
654 rev, | |
655 p1, | |
656 p2, | |
657 base, | |
658 self.collapsef, | |
659 wctx=self.wctx, | |
660 ) | |
621 if not self.collapsef: | 661 if not self.collapsef: |
622 merging = p2 != nullrev | 662 merging = p2 != nullrev |
623 editform = cmdutil.mergeeditform(merging, b'rebase') | 663 editform = cmdutil.mergeeditform(merging, b'rebase') |
624 editor = cmdutil.getcommiteditor( | 664 editor = cmdutil.getcommiteditor( |
625 editform=editform, **pycompat.strkwargs(opts) | 665 editform=editform, **pycompat.strkwargs(opts) |
1098 overrides = {(b'rebase', b'singletransaction'): True} | 1138 overrides = {(b'rebase', b'singletransaction'): True} |
1099 with ui.configoverride(overrides, b'rebase'): | 1139 with ui.configoverride(overrides, b'rebase'): |
1100 _origrebase( | 1140 _origrebase( |
1101 ui, repo, action, opts, rbsrt, | 1141 ui, repo, action, opts, rbsrt, |
1102 ) | 1142 ) |
1103 except error.InMemoryMergeConflictsError: | 1143 except error.ConflictResolutionRequired: |
1104 ui.status(_(b'hit a merge conflict\n')) | 1144 ui.status(_(b'hit a merge conflict\n')) |
1105 return 1 | 1145 return 1 |
1106 except error.Abort: | 1146 except error.Abort: |
1107 needsabort = False | 1147 needsabort = False |
1108 raise | 1148 raise |