[PATCH 10 of 23 v3] rebase: move local variables related to keeping things unchanged to the RRS

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


# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1464869213 -3600
#      Thu Jun 02 13:06:53 2016 +0100
# Node ID 882dbd7618d2ff2d535a8863b44e1e69bc4c720d
# Parent  7c29b7287e5ba89e262bbd51e980eff4ffd706a1
rebase: move local variables related to keeping things unchanged to the RRS

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

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -158,6 +158,12 @@
         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 @@
         wlock = repo.wlock()
         lock = repo.lock()
 
-        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 @@
 
             try:
                 (rtstate.originalwd, rtstate.target, rtstate.state,
-                 rtstate.skipped, rtstate.collapsef, keepf, keepbranchesf,
-                 rtstate.external, rtstate.activebookmark) = restorestatus(repo)
+                 rtstate.skipped, rtstate.collapsef, rtstate.keepf,
+                 rtstate.keepbranchesf, rtstate.external,
+                 rtstate.activebookmark) = restorestatus(repo)
                 rtstate.collapsemsg = restorecollapsemsg(repo)
             except error.RepoLookupError:
                 if rtstate.abortf:
@@ -348,7 +349,7 @@
                 return _nothingtorebase()
 
             allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
-            if (not (keepf or allowunstable)
+            if (not (rtstate.keepf or allowunstable)
                   and repo.revs('first(children(%ld) - %ld)',
                                 rebaseset, rebaseset)):
                 raise error.Abort(
@@ -378,7 +379,7 @@
                 return _nothingtorebase()
 
             root = min(rebaseset)
-            if not keepf and not repo[root].mutable():
+            if not rtstate.keepf and not repo[root].mutable():
                 raise error.Abort(_("can't rebase public changeset %s")
                                  % repo[root],
                                  hint=_('see "hg help phases" for details'))
@@ -391,10 +392,10 @@
                 rtstate.external = externalparent(repo, rtstate.state,
                                                   rtstate.targetancestors)
 
-            if dest.closesbranch() and not keepbranchesf:
+            if dest.closesbranch() and not rtstate.keepbranchesf:
                 ui.status(_('reopening closed branch head %s\n') % dest)
 
-        if keepbranchesf:
+        if rtstate.keepbranchesf:
             # insert _savebranch at the start of extrafns so if
             # there's a user-provided extrafn it can clobber branch if
             # desired
@@ -440,8 +441,8 @@
                                              rtstate.targetancestors,
                                              obsoletenotrebased)
                 storestatus(repo, rtstate.originalwd, rtstate.target,
-                            rtstate.state, rtstate.collapsef, keepf,
-                            keepbranchesf, rtstate.external,
+                            rtstate.state, rtstate.collapsef, rtstate.keepf,
+                            rtstate.keepbranchesf, rtstate.external,
                             rtstate.activebookmark)
                 storecollapsemsg(repo, rtstate.collapsemsg)
                 if len(repo[None].parents()) == 2:
@@ -464,7 +465,7 @@
                     editor = cmdutil.getcommiteditor(editform=editform, **opts)
                     newnode = concludenode(repo, rev, p1, p2, extrafn=extrafn,
                                            editor=editor,
-                                           keepbranches=keepbranchesf,
+                                           keepbranches=rtstate.keepbranchesf,
                                            date=rtstate.date)
                 else:
                     # Skip commit if we are collapsing
@@ -503,7 +504,7 @@
         ui.progress(_('rebasing'), None)
         ui.note(_('rebase merging completed\n'))
 
-        if rtstate.collapsef and not keepopen:
+        if rtstate.collapsef and not rtstate.keepopen:
             p1, p2, _base = defineparents(repo, min(rtstate.state),
                                           rtstate.target, rtstate.state,
                                           rtstate.targetancestors,
@@ -523,7 +524,7 @@
             newnode = concludenode(repo, rev, p1, rtstate.external,
                                    commitmsg=commitmsg,
                                    extrafn=extrafn, editor=editor,
-                                   keepbranches=keepbranchesf,
+                                   keepbranches=rtstate.keepbranchesf,
                                    date=rtstate.date)
             if newnode is None:
                 newrev = rtstate.target
@@ -556,7 +557,7 @@
             ui.note(_("update back to initial working directory parent\n"))
             hg.updaterepo(repo, newwd, False)
 
-        if not keepf:
+        if not rtstate.keepf:
             collapsedas = None
             if rtstate.collapsef:
                 collapsedas = newnode


More information about the Mercurial-devel mailing list