Patchwork [3,of,6,v7] rebase: move local variables 'date' and 'extrafns' to the RR class

login
register
mail settings
Submitter Kostia Balytskyi
Date June 21, 2016, 2:28 p.m.
Message ID <6a52aae09fc891a1a841.1466519309@dev1902.lla1.facebook.com>
Download mbox | patch
Permalink /patch/15560/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Kostia Balytskyi - June 21, 2016, 2:28 p.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1466515763 25200
#      Tue Jun 21 06:29:23 2016 -0700
# Node ID 6a52aae09fc891a1a841fbd002995c5aefb2a9d6
# Parent  eedb66de1a3c4f771ce6deb72301cbb5b3662f3e
rebase: move local variables 'date' and 'extrafns' to the RR class

This commit moves the following variables, local to the rebase function to be
fields of the rebaseruntime:
 -date
 -extrafns

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -141,6 +141,12 @@  class rebaseruntime(object):
 
         self.collapsef = opts.get('collapse', False)
         self.collapsemsg = cmdutil.logmessage(ui, opts)
+        self.date = opts.get('date', None)
+
+        e = opts.get('extrafn') # internal, used by e.g. hgsubversion
+        self.extrafns = [_savegraft]
+        if e:
+            self.extrafns = [e]
 
 @command('rebase',
     [('s', 'source', '',
@@ -269,11 +275,6 @@  def rebase(ui, repo, **opts):
         destspace = opts.get('_destspace')
         contf = opts.get('continue')
         abortf = opts.get('abort')
-        date = opts.get('date', None)
-        e = opts.get('extrafn') # internal, used by e.g. hgsubversion
-        extrafns = [_savegraft]
-        if e:
-            extrafns = [e]
         keepf = opts.get('keep', False)
         keepbranchesf = opts.get('keepbranches', False)
         # keepopen is not meant for use on the command line, but by
@@ -395,7 +396,7 @@  def rebase(ui, repo, **opts):
             # insert _savebranch at the start of extrafns so if
             # there's a user-provided extrafn it can clobber branch if
             # desired
-            extrafns.insert(0, _savebranch)
+            rbsrt.extrafns.insert(0, _savebranch)
             if rbsrt.collapsef:
                 branches = set()
                 for rev in rbsrt.state:
@@ -415,7 +416,7 @@  def rebase(ui, repo, **opts):
         if rbsrt.activebookmark:
             bookmarks.deactivate(repo)
 
-        extrafn = _makeextrafn(extrafns)
+        extrafn = _makeextrafn(rbsrt.extrafns)
 
         sortedstate = sorted(rbsrt.state)
         total = len(sortedstate)
@@ -462,7 +463,7 @@  def rebase(ui, repo, **opts):
                     newnode = concludenode(repo, rev, p1, p2, extrafn=extrafn,
                                            editor=editor,
                                            keepbranches=keepbranchesf,
-                                           date=date)
+                                           date=rbsrt.date)
                 else:
                     # Skip commit if we are collapsing
                     repo.dirstate.beginparentchange()
@@ -521,7 +522,7 @@  def rebase(ui, repo, **opts):
                                    commitmsg=commitmsg,
                                    extrafn=extrafn, editor=editor,
                                    keepbranches=keepbranchesf,
-                                   date=date)
+                                   date=rbsrt.date)
             if newnode is None:
                 newrev = rbsrt.target
             else: