Patchwork [4,of,6,v7] rebase: move local variables related to keeping things unchanged to the RR

login
register
mail settings
Submitter Kostia Balytskyi
Date June 21, 2016, 2:28 p.m.
Message ID <d66132f99109ad43d7a3.1466519310@dev1902.lla1.facebook.com>
Download mbox | patch
Permalink /patch/15561/
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 d66132f99109ad43d7a3272b396b5a2a9ad24091
# Parent  6a52aae09fc891a1a841fbd002995c5aefb2a9d6
rebase: move local variables related to keeping things unchanged to the RR

This commit moves the following variables, local to the rebase function to be
fields of the rebaseruntime:
 -keepf
 -keepbranchesf
 -keepopen

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -148,6 +148,12 @@  class rebaseruntime(object):
         if e:
             self.extrafns = [e]
 
+        self.keepf = opts.get('keep', False)
+        self.keepbranchesf = opts.get('keepbranches', False)
+        # keepopen is not meant for use on the command line, but by
+        # other extensions
+        self.keepopen = opts.get('keepopen', False)
+
 @command('rebase',
     [('s', 'source', '',
      _('rebase the specified changeset and descendants'), _('REV')),
@@ -275,12 +281,6 @@  def rebase(ui, repo, **opts):
         destspace = opts.get('_destspace')
         contf = opts.get('continue')
         abortf = opts.get('abort')
-        keepf = opts.get('keep', False)
-        keepbranchesf = opts.get('keepbranches', False)
-        # keepopen is not meant for use on the command line, but by
-        # other extensions
-        keepopen = opts.get('keepopen', False)
-
         if opts.get('interactive'):
             try:
                 if extensions.find('histedit'):
@@ -310,8 +310,9 @@  def rebase(ui, repo, **opts):
 
             try:
                 (rbsrt.originalwd, rbsrt.target, rbsrt.state,
-                 rbsrt.skipped, rbsrt.collapsef, keepf, keepbranchesf,
-                 rbsrt.external, rbsrt.activebookmark) = restorestatus(repo)
+                 rbsrt.skipped, rbsrt.collapsef, rbsrt.keepf,
+                 rbsrt.keepbranchesf, rbsrt.external,
+                 rbsrt.activebookmark) = restorestatus(repo)
                 rbsrt.collapsemsg = restorecollapsemsg(repo)
             except error.RepoLookupError:
                 if abortf:
@@ -347,7 +348,7 @@  def rebase(ui, repo, **opts):
                 return _nothingtorebase()
 
             allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
-            if (not (keepf or allowunstable)
+            if (not (rbsrt.keepf or allowunstable)
                   and repo.revs('first(children(%ld) - %ld)',
                                 rebaseset, rebaseset)):
                 raise error.Abort(
@@ -377,7 +378,7 @@  def rebase(ui, repo, **opts):
                 return _nothingtorebase()
 
             root = min(rebaseset)
-            if not keepf and not repo[root].mutable():
+            if not rbsrt.keepf and not repo[root].mutable():
                 raise error.Abort(_("can't rebase public changeset %s")
                                  % repo[root],
                                  hint=_('see "hg help phases" for details'))
@@ -389,10 +390,10 @@  def rebase(ui, repo, **opts):
                 rbsrt.external = externalparent(repo, rbsrt.state,
                                                 rbsrt.targetancestors)
 
-            if dest.closesbranch() and not keepbranchesf:
+            if dest.closesbranch() and not rbsrt.keepbranchesf:
                 ui.status(_('reopening closed branch head %s\n') % dest)
 
-        if keepbranchesf:
+        if rbsrt.keepbranchesf:
             # insert _savebranch at the start of extrafns so if
             # there's a user-provided extrafn it can clobber branch if
             # desired
@@ -438,8 +439,8 @@  def rebase(ui, repo, **opts):
                                              rbsrt.targetancestors,
                                              obsoletenotrebased)
                 storestatus(repo, rbsrt.originalwd, rbsrt.target,
-                            rbsrt.state, rbsrt.collapsef, keepf,
-                            keepbranchesf, rbsrt.external,
+                            rbsrt.state, rbsrt.collapsef, rbsrt.keepf,
+                            rbsrt.keepbranchesf, rbsrt.external,
                             rbsrt.activebookmark)
                 storecollapsemsg(repo, rbsrt.collapsemsg)
                 if len(repo[None].parents()) == 2:
@@ -462,7 +463,7 @@  def rebase(ui, repo, **opts):
                     editor = cmdutil.getcommiteditor(editform=editform, **opts)
                     newnode = concludenode(repo, rev, p1, p2, extrafn=extrafn,
                                            editor=editor,
-                                           keepbranches=keepbranchesf,
+                                           keepbranches=rbsrt.keepbranchesf,
                                            date=rbsrt.date)
                 else:
                     # Skip commit if we are collapsing
@@ -501,7 +502,7 @@  def rebase(ui, repo, **opts):
         ui.progress(_('rebasing'), None)
         ui.note(_('rebase merging completed\n'))
 
-        if rbsrt.collapsef and not keepopen:
+        if rbsrt.collapsef and not rbsrt.keepopen:
             p1, p2, _base = defineparents(repo, min(rbsrt.state),
                                           rbsrt.target, rbsrt.state,
                                           rbsrt.targetancestors,
@@ -521,7 +522,7 @@  def rebase(ui, repo, **opts):
             newnode = concludenode(repo, rev, p1, rbsrt.external,
                                    commitmsg=commitmsg,
                                    extrafn=extrafn, editor=editor,
-                                   keepbranches=keepbranchesf,
+                                   keepbranches=rbsrt.keepbranchesf,
                                    date=rbsrt.date)
             if newnode is None:
                 newrev = rbsrt.target
@@ -559,7 +560,7 @@  def rebase(ui, repo, **opts):
             ui.note(_("update back to initial working directory parent\n"))
             hg.updaterepo(repo, newwd, False)
 
-        if not keepf:
+        if not rbsrt.keepf:
             collapsedas = None
             if rbsrt.collapsef:
                 collapsedas = newnode