[PATCH 05 of 23 v3] rebase: move revset-defining local variables to the RRS class

Kostia Balytskyi ikostia at fb.com
Thu Jun 2 10:13:46 EDT 2016


# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1464866782 -3600
#      Thu Jun 02 12:26:22 2016 +0100
# Node ID c4242a2f33439dc7c0332b0b3b83796a15673ba2
# Parent  10b0606ad889fd76ff4db51669bf8b82b87ccd5b
rebase: move revset-defining local variables to the RRS class

This commit moves:
 -destf
 -srcf
 -basef
 -revf
to be fields of the previously introduced RebaseRuntimeState class.

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -121,7 +121,7 @@
 
 class RebaseRuntimeState(object):
     """This class is a container for rebase runtime state"""
-    def __init__(self):
+    def __init__(self, opts):
         self.originalwd = None
         self.external = nullrev
         # Mapping between the old revision id and either what is the new rebased
@@ -133,6 +133,12 @@
         self.skipped = set()
         self.targetancestors = set()
 
+        # Validate input and define rebasing points
+        self.destf = opts.get('dest', None)
+        self.srcf = opts.get('source', None)
+        self.basef = opts.get('base', None)
+        self.revf = opts.get('rev', [])
+
 @command('rebase',
     [('s', 'source', '',
      _('rebase the specified changeset and descendants'), _('REV')),
@@ -243,18 +249,13 @@
     unresolved conflicts.
 
     """
-    rtstate = RebaseRuntimeState()
+    rtstate = RebaseRuntimeState(opts)
 
     lock = wlock = None
     try:
         wlock = repo.wlock()
         lock = repo.lock()
 
-        # Validate input and define rebasing points
-        destf = opts.get('dest', None)
-        srcf = opts.get('source', None)
-        basef = opts.get('base', None)
-        revf = opts.get('rev', [])
         # search default destination in this space
         # used in the 'hg pull --rebase' case, see issue 5214.
         destspace = opts.get('_destspace')
@@ -294,7 +295,7 @@
             if collapsef:
                 raise error.Abort(
                     _('cannot use collapse with continue or abort'))
-            if srcf or basef or destf:
+            if rtstate.srcf or rtstate.basef or rtstate.destf:
                 raise error.Abort(
                     _('abort and continue do not allow specifying revisions'))
             if abortf and opts.get('tool', False):
@@ -333,7 +334,8 @@
                 _checkobsrebase(repo, ui, rebaseobsrevs, rebasesetrevs,
                                 rebaseobsskipped)
         else:
-            dest, rebaseset = _definesets(ui, repo, destf, srcf, basef, revf,
+            dest, rebaseset = _definesets(ui, repo, rtstate.destf, rtstate.srcf,
+                                          rtstate.basef, rtstate.revf,
                                           destspace=destspace)
             if dest is None:
                 return _nothingtorebase()


More information about the Mercurial-devel mailing list