Patchwork D9074: rebase: add dryrun property to rebaseruntime

login
register
mail settings
Submitter phabricator
Date Sept. 23, 2020, 5:29 p.m.
Message ID <differential-rev-PHID-DREV-kskfii4pzvagpzdcavlc-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47260/
State Superseded
Headers show

Comments

phabricator - Sept. 23, 2020, 5:29 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I want to be able to check the property in
  `rebaseruntime._rebasenode()`. Passing the value via the runtime is a
  convenient way.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -165,7 +165,7 @@ 
 class rebaseruntime(object):
     """This class is a container for rebase runtime state"""
 
-    def __init__(self, repo, ui, inmemory=False, opts=None):
+    def __init__(self, repo, ui, inmemory=False, dryrun=False, opts=None):
         if opts is None:
             opts = {}
 
@@ -211,6 +211,7 @@ 
         self.obsoletenotrebased = {}
         self.obsoletewithoutsuccessorindestination = set()
         self.inmemory = inmemory
+        self.dryrun = dryrun
         self.stateobj = statemod.cmdstate(repo, b'rebasestate')
 
     @property
@@ -1087,7 +1088,7 @@ 
 
 
 def _dryrunrebase(ui, repo, action, opts):
-    rbsrt = rebaseruntime(repo, ui, inmemory=True, opts=opts)
+    rbsrt = rebaseruntime(repo, ui, inmemory=True, dryrun=True, opts=opts)
     confirm = opts.get(b'confirm')
     if confirm:
         ui.status(_(b'starting in-memory rebase\n'))
@@ -1101,7 +1102,7 @@ 
             overrides = {(b'rebase', b'singletransaction'): True}
             with ui.configoverride(overrides, b'rebase'):
                 _origrebase(
-                    ui, repo, action, opts, rbsrt, leaveunfinished=True,
+                    ui, repo, action, opts, rbsrt,
                 )
         except error.InMemoryMergeConflictsError:
             ui.status(_(b'hit a merge conflict\n'))
@@ -1143,11 +1144,11 @@ 
 
 
 def _dorebase(ui, repo, action, opts, inmemory=False):
-    rbsrt = rebaseruntime(repo, ui, inmemory, opts)
+    rbsrt = rebaseruntime(repo, ui, inmemory, opts=opts)
     return _origrebase(ui, repo, action, opts, rbsrt)
 
 
-def _origrebase(ui, repo, action, opts, rbsrt, leaveunfinished=False):
+def _origrebase(ui, repo, action, opts, rbsrt):
     assert action != b'stop'
     with repo.wlock(), repo.lock():
         if opts.get(b'interactive'):
@@ -1221,7 +1222,7 @@ 
                 dsguard = dirstateguard.dirstateguard(repo, b'rebase')
             with util.acceptintervention(dsguard):
                 rbsrt._performrebase(tr)
-                if not leaveunfinished:
+                if not rbsrt.dryrun:
                     rbsrt._finishrebase()