diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -644,6 +644,12 @@ repo['.'].node() == repo._bookmarks[self.activebookmark]): bookmarks.activate(repo, self.activebookmark) + def _abortunfinishedrebase(self, backup=False, suppwarns=True): + repo = self.repo + with repo.wlock(), repo.lock(): + retcode = self._prepareabortorcontinue(isabort=True) + return retcode + @command('rebase', [('s', 'source', '', _('rebase the specified changeset and descendants'), _('REV')), @@ -818,19 +824,7 @@ opts[r'dest'] = '_destautoorphanrebase(SRC)' if dryrun: - try: - overrides = {('rebase', 'singletransaction'): True} - with ui.configoverride(overrides, 'rebase'): - _origrebase(ui, repo, inmemory=True, leaveunfinished=True, - **opts) - except error.InMemoryMergeConflictsError: - ui.status(_('hit a merge conflict\n')) - return 1 - else: - ui.status(_('there will be no conflict, you can rebase\n')) - return 0 - finally: - _origrebase(ui, repo, abort=True) + return _dryrunrebase(ui, repo, **opts) elif inmemory: try: # in-memory merge doesn't support conflicts, so if we hit any, abort @@ -846,6 +840,24 @@ else: return _origrebase(ui, repo, **opts) +def _dryrunrebase(ui, repo, **opts): + leaveunfinished = True + inmemory = True + rbsrt = rebaseruntime(repo, ui, inmemory, opts) + try: + overrides = {('rebase', 'singletransaction'): True} + with ui.configoverride(overrides, 'rebase'): + _origrebase(ui, repo, inmemory=True, + leaveunfinished=leaveunfinished, **opts) + except error.InMemoryMergeConflictsError: + ui.status(_('hit a merge conflict\n')) + return 1 + else: + ui.status(_('there will be no conflict, you can rebase\n')) + return 0 + finally: + rbsrt._abortunfinishedrebase() + def _origrebase(ui, repo, inmemory=False, leaveunfinished=False, **opts): opts = pycompat.byteskwargs(opts) rbsrt = rebaseruntime(repo, ui, inmemory, opts)