Patchwork D2918: rebase: inline _makextrafn() now that we have only one caller

login
register
mail settings
Submitter phabricator
Date March 21, 2018, 6:11 p.m.
Message ID <differential-rev-PHID-DREV-omibapz2sar5vy73doqr-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/29705/
State Superseded
Headers show

Comments

phabricator - March 21, 2018, 6:11 p.m.
martinvonz created this revision.
martinvonz added a reviewer: phillco.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Also avoid even creating a function since we just end up calling it
  right away.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2918

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS




To: martinvonz, phillco, #hg-reviewers
Cc: mercurial-devel
phabricator - March 21, 2018, 11:40 p.m.
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  The ability to register extra functions seems like the important functionality here. And `self.extrafns` is preserved. So I don't think anyone will miss the old function.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2918

To: martinvonz, phillco, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -87,17 +87,6 @@ 
 def _savebranch(ctx, extra):
     extra['branch'] = ctx.branch()
 
-def _makeextrafn(copiers):
-    """make an extrafn out of the given copy-functions.
-
-    A copy function takes a context and an extra dict, and mutates the
-    extra dict as needed based on the given context.
-    """
-    def extrafn(ctx, extra):
-        for c in copiers:
-            c(ctx, extra)
-    return extrafn
-
 def _destrebase(repo, sourceset, destspace=None):
     """small wrapper around destmerge to pass the right extra args
 
@@ -457,10 +446,9 @@ 
         ctx = repo[rev]
         if commitmsg is None:
             commitmsg = ctx.description()
-        extrafn = _makeextrafn(self.extrafns)
         extra = {'rebase_source': ctx.hex()}
-        if extrafn:
-            extrafn(ctx, extra)
+        for c in self.extrafns:
+            c(ctx, extra)
         if self.inmemory:
             newnode = concludememorynode(repo, ctx, p1, p2,
                 wctx=self.wctx,