[PATCH 09 of 23 v2] rebase: move date and extrafns local variables to the class

Kostia Balytskyi ikostia at fb.com
Tue May 31 19:23:29 EDT 2016


# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1464602326 -3600
#      Mon May 30 10:58:46 2016 +0100
# Node ID 8ae75e839ffc96f08af8b2ac4863826c47b88ce6
# Parent  b068d25c46ba2c0e555f29549ae6ba0808132148
rebase: move date and extrafns local variables to the class

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -151,6 +151,12 @@
         self.abortf = opts.get('abort')
         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 @@
         wlock = repo.wlock()
         lock = repo.lock()
 
-        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
@@ -397,7 +398,7 @@
             # 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)
+            rtstate.extrafns.insert(0, _savebranch)
             if rtstate.collapsef:
                 branches = set()
                 for rev in rtstate.state:
@@ -417,7 +418,7 @@
         if rtstate.activebookmark:
             bookmarks.deactivate(repo)
 
-        extrafn = _makeextrafn(extrafns)
+        extrafn = _makeextrafn(rtstate.extrafns)
 
         sortedstate = sorted(rtstate.state)
         total = len(sortedstate)
@@ -464,7 +465,7 @@
                     newnode = concludenode(repo, rev, p1, p2, extrafn=extrafn,
                                            editor=editor,
                                            keepbranches=keepbranchesf,
-                                           date=date)
+                                           date=rtstate.date)
                 else:
                     # Skip commit if we are collapsing
                     repo.dirstate.beginparentchange()
@@ -523,7 +524,7 @@
                                    commitmsg=commitmsg,
                                    extrafn=extrafn, editor=editor,
                                    keepbranches=keepbranchesf,
-                                   date=date)
+                                   date=rtstate.date)
             if newnode is None:
                 newrev = rtstate.target
             else:


More information about the Mercurial-devel mailing list