changeset 38500:c92fdc27cbdd

rebase: extract dryrun as a function To avoid more number of indented blocks and make it easier to add additional functionality in dryrun, extracted as a function. Differential Revision: https://phab.mercurial-scm.org/D3855
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Thu, 28 Jun 2018 23:57:15 +0530
parents ba6d2c32f34a
children 9c3b48fb7ac5
files hgext/rebase.py
diffstat 1 files changed, 19 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Thu Jun 28 23:36:45 2018 +0530
+++ b/hgext/rebase.py	Thu Jun 28 23:57:15 2018 +0530
@@ -818,22 +818,7 @@
         opts[r'dest'] = '_destautoorphanrebase(SRC)'
 
     if dryrun:
-        rbsrt = rebaseruntime(repo, ui, inmemory=True,
-                              opts=pycompat.byteskwargs(opts))
-        with repo.wlock(), repo.lock():
-            try:
-                overrides = {('rebase', 'singletransaction'): True}
-                with ui.configoverride(overrides, 'rebase'):
-                    _origrebase(ui, repo, inmemory=True, rbsrt=rbsrt,
-                                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:
-                rbsrt._prepareabortorcontinue(isabort=True)
+        return _dryrunrebase(ui, repo, **opts)
     elif inmemory:
         try:
             # in-memory merge doesn't support conflicts, so if we hit any, abort
@@ -849,6 +834,24 @@
     else:
         return _origrebase(ui, repo, **opts)
 
+def _dryrunrebase(ui, repo, **opts):
+    rbsrt = rebaseruntime(repo, ui, inmemory=True,
+                          opts=pycompat.byteskwargs(opts))
+    with repo.wlock(), repo.lock():
+        try:
+            overrides = {('rebase', 'singletransaction'): True}
+            with ui.configoverride(overrides, 'rebase'):
+                _origrebase(ui, repo, inmemory=True, rbsrt=rbsrt,
+                            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:
+            rbsrt._prepareabortorcontinue(isabort=True)
+
 def _origrebase(ui, repo, inmemory=False, leaveunfinished=False, rbsrt=None,
                 **opts):
     opts = pycompat.byteskwargs(opts)