Patchwork [5,of,7,v5] rebase: move revset-defining local variables to the RRS class

login
register
mail settings
Submitter Kostia Balytskyi
Date June 13, 2016, 9:28 p.m.
Message ID <0d2ccd17e15d04bc6cb6.1465853283@ikostia-mbp>
Download mbox | patch
Permalink /patch/15483/
State Superseded
Headers show

Comments

Kostia Balytskyi - June 13, 2016, 9:28 p.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1465837045 -3600
#      Mon Jun 13 17:57:25 2016 +0100
# Node ID 0d2ccd17e15d04bc6cb6dbab1ea3912c9a33fd3d
# Parent  4f6edbc94d98ef56cf9566278e605f11873d6037
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.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -121,7 +121,7 @@  def _revsetdestrebase(repo, subset, x):
 
 class rebaseruntime(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 @@  class rebaseruntime(object):
         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 @@  def rebase(ui, repo, **opts):
     unresolved conflicts.
 
     """
-    rbsrt = rebaseruntime()
+    rbsrt = rebaseruntime(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 @@  def rebase(ui, repo, **opts):
             if collapsef:
                 raise error.Abort(
                     _('cannot use collapse with continue or abort'))
-            if srcf or basef or destf:
+            if rbsrt.srcf or rbsrt.basef or rbsrt.destf:
                 raise error.Abort(
                     _('abort and continue do not allow specifying revisions'))
             if abortf and opts.get('tool', False):
@@ -333,7 +334,8 @@  def rebase(ui, repo, **opts):
                 _checkobsrebase(repo, ui, rebaseobsrevs, rebasesetrevs,
                                 rebaseobsskipped)
         else:
-            dest, rebaseset = _definesets(ui, repo, destf, srcf, basef, revf,
+            dest, rebaseset = _definesets(ui, repo, rbsrt.destf, rbsrt.srcf,
+                                          rbsrt.basef, rbsrt.revf,
                                           destspace=destspace)
             if dest is None:
                 return _nothingtorebase()