changeset 38485:56b2074114b1

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
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Wed, 27 Jun 2018 12:24:21 +0530
parents e9e61fbac787
children 4c0683655599
files hgext/rebase.py
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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