Patchwork D3855: rebase: extract dryrun as a function

login
register
mail settings
Submitter phabricator
Date June 30, 2018, 1:47 a.m.
Message ID <deeec4b25b38918c47e04c42afab3592@localhost.localdomain>
Download mbox | patch
Permalink /patch/32519/
State Not Applicable
Headers show

Comments

phabricator - June 30, 2018, 1:47 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc92fdc27cbdd: rebase: extract dryrun as a function (authored by khanchi97, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D3855?vs=9355&id=9370#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3855?vs=9355&id=9370

REVISION DETAIL
  https://phab.mercurial-scm.org/D3855

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS




To: khanchi97, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -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)