rebase: replace extrafn field with _makeextrafn invocations
authorKostia Balytskyi <ikostia@fb.com>
Thu, 14 Jul 2016 02:59:27 -0700
changeset 29551 333dd3ab8fb2
parent 29550 1c22400db72d
child 29552 db26925bdbb0
rebase: replace extrafn field with _makeextrafn invocations As per Yuya's advice, we would like to slightly reduce the amount of state which is stored in rebaseruntime class. In this case, we don't need to store extrafn field, as we can produce the necessary value by calling _makeextrafn and the perf overhead is negligible.
hgext/rebase.py
--- a/hgext/rebase.py	Mon Jul 04 11:18:03 2016 -0700
+++ b/hgext/rebase.py	Thu Jul 14 02:59:27 2016 -0700
@@ -148,7 +148,6 @@
         self.extrafns = [_savegraft]
         if e:
             self.extrafns = [e]
-        self.extrafn = None
 
         self.keepf = opts.get('keep', False)
         self.keepbranchesf = opts.get('keepbranches', False)
@@ -336,8 +335,6 @@
         if self.activebookmark:
             bookmarks.deactivate(repo)
 
-        self.extrafn = _makeextrafn(self.extrafns)
-
         self.sortedstate = sorted(self.state)
         total = len(self.sortedstate)
         pos = 0
@@ -381,7 +378,7 @@
                     editform = cmdutil.mergeeditform(merging, 'rebase')
                     editor = cmdutil.getcommiteditor(editform=editform, **opts)
                     newnode = concludenode(repo, rev, p1, p2,
-                                           extrafn=self.extrafn,
+                                           extrafn=_makeextrafn(self.extrafns),
                                            editor=editor,
                                            keepbranches=self.keepbranchesf,
                                            date=self.date)
@@ -444,7 +441,8 @@
             revtoreuse = self.sortedstate[-1]
             newnode = concludenode(repo, revtoreuse, p1, self.external,
                                    commitmsg=commitmsg,
-                                   extrafn=self.extrafn, editor=editor,
+                                   extrafn=_makeextrafn(self.extrafns),
+                                   editor=editor,
                                    keepbranches=self.keepbranchesf,
                                    date=self.date)
             if newnode is None: