# HG changeset patch # User Sushil khanchi # Date 1530082461 -19800 # Node ID 56b2074114b19e12abd9cd4c378d58b702232705 # Parent e9e61fbac7870075700d12c83dcb5986ccd21da8 rebase: refactor dryrun implementation This patch refactor dry-run code to make it easy to add additional functionality in dryrun. Otherwise we had to add every functionality through _origrebase() which does not seem a good implementation. Differential Revision: https://phab.mercurial-scm.org/D3849 diff -r e9e61fbac787 -r 56b2074114b1 hgext/rebase.py --- a/hgext/rebase.py Sun Jul 02 00:32:09 2017 -0400 +++ b/hgext/rebase.py Wed Jun 27 12:24:21 2018 +0530 @@ -818,11 +818,14 @@ opts[r'dest'] = '_destautoorphanrebase(SRC)' if dryrun: + 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=True, - **opts) + _origrebase(ui, repo, inmemory=True, rbsrt=rbsrt, + leaveunfinished=leaveunfinished, **opts) except error.InMemoryMergeConflictsError: ui.status(_('hit a merge conflict\n')) return 1 @@ -830,7 +833,8 @@ ui.status(_('there will be no conflict, you can rebase\n')) return 0 finally: - _origrebase(ui, repo, abort=True) + with repo.wlock(), repo.lock(): + rbsrt._prepareabortorcontinue(isabort=True) elif inmemory: try: # in-memory merge doesn't support conflicts, so if we hit any, abort @@ -846,9 +850,11 @@ else: return _origrebase(ui, repo, **opts) -def _origrebase(ui, repo, inmemory=False, leaveunfinished=False, **opts): +def _origrebase(ui, repo, inmemory=False, leaveunfinished=False, rbsrt=None, + **opts): opts = pycompat.byteskwargs(opts) - rbsrt = rebaseruntime(repo, ui, inmemory, opts) + if not rbsrt: + rbsrt = rebaseruntime(repo, ui, inmemory, opts) with repo.wlock(), repo.lock(): # Validate input and define rebasing points