rebase: split _origrebase() for conveniece in dryrun
authorSushil khanchi <sushilkhanchi97@gmail.com>
Fri, 29 Jun 2018 00:22:50 +0530
changeset 38497 9c3b48fb7ac5
parent 38496 c92fdc27cbdd
child 38498 c892a30bafb9
rebase: split _origrebase() for conveniece in dryrun This patch split _origrebase() method by extracting rbsrt part from that to make it easy to implement dryrun in more elegant way than before. Differential Revision: https://phab.mercurial-scm.org/D3856
hgext/rebase.py
--- a/hgext/rebase.py	Thu Jun 28 23:57:15 2018 +0530
+++ b/hgext/rebase.py	Fri Jun 29 00:22:50 2018 +0530
@@ -825,14 +825,14 @@
             # and re-run as an on-disk merge.
             overrides = {('rebase', 'singletransaction'): True}
             with ui.configoverride(overrides, 'rebase'):
-                return _origrebase(ui, repo, inmemory=inmemory, **opts)
+                return _dorebase(ui, repo, inmemory=inmemory, **opts)
         except error.InMemoryMergeConflictsError:
             ui.warn(_('hit merge conflicts; re-running rebase without in-memory'
                       ' merge\n'))
-            _origrebase(ui, repo, abort=True)
-            return _origrebase(ui, repo, inmemory=False, **opts)
+            _dorebase(ui, repo, abort=True)
+            return _dorebase(ui, repo, inmemory=False, **opts)
     else:
-        return _origrebase(ui, repo, **opts)
+        return _dorebase(ui, repo, **opts)
 
 def _dryrunrebase(ui, repo, **opts):
     rbsrt = rebaseruntime(repo, ui, inmemory=True,
@@ -841,7 +841,7 @@
         try:
             overrides = {('rebase', 'singletransaction'): True}
             with ui.configoverride(overrides, 'rebase'):
-                _origrebase(ui, repo, inmemory=True, rbsrt=rbsrt,
+                _origrebase(ui, repo, rbsrt, inmemory=True,
                             leaveunfinished=True, **opts)
         except error.InMemoryMergeConflictsError:
             ui.status(_('hit a merge conflict\n'))
@@ -852,12 +852,12 @@
         finally:
             rbsrt._prepareabortorcontinue(isabort=True)
 
-def _origrebase(ui, repo, inmemory=False, leaveunfinished=False, rbsrt=None,
-                **opts):
+def _dorebase(ui, repo, inmemory=False, **opts):
+    rbsrt = rebaseruntime(repo, ui, inmemory, pycompat.byteskwargs(opts))
+    return _origrebase(ui, repo, rbsrt, inmemory=inmemory, **opts)
+
+def _origrebase(ui, repo, rbsrt, inmemory=False, leaveunfinished=False, **opts):
     opts = pycompat.byteskwargs(opts)
-    if not rbsrt:
-        rbsrt = rebaseruntime(repo, ui, inmemory, opts)
-
     with repo.wlock(), repo.lock():
         # Validate input and define rebasing points
         destf = opts.get('dest', None)