[PATCH 2 of 2] rebase: replace extrafn field with _makeextrafn invocations

Kostia Balytskyi ikostia at fb.com
Thu Jul 14 06:21:08 EDT 2016


# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1468490367 25200
#      Thu Jul 14 02:59:27 2016 -0700
# Node ID 2beb390fcc108e887567d2f37ee69908d61f5ec2
# Parent  52433f89f816e21ca992ac8c4a41cba0345f1b73
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.

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -148,7 +148,6 @@ class rebaseruntime(object):
         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 @@ class rebaseruntime(object):
         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 @@ class rebaseruntime(object):
                     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 @@ class rebaseruntime(object):
             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:


More information about the Mercurial-devel mailing list