Patchwork [3,of,6,cg3,v3] changegroup: remove one special case from lookupmflinknode

login
register
mail settings
Submitter Augie Fackler
Date Dec. 4, 2015, 7:38 p.m.
Message ID <a1ae74e5441d7ec1abb7.1449257932@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/11815/
State Accepted
Headers show

Comments

Augie Fackler - Dec. 4, 2015, 7:38 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1449244546 18000
#      Fri Dec 04 10:55:46 2015 -0500
# Node ID a1ae74e5441d7ec1abb76b4699e394b06f9b9924
# Parent  ef0693b1540667fd183fe1364dbf308f919a0fd6
# EXP-Topic cg3
changegroup: remove one special case from lookupmflinknode

In the fastpathlinkrev case, lookupmflinknode was a very complicated
way of saying mfs.__getitem__, so let's just get that case out of our
way so it's easier to understand what's going on.

Timings for bundle --all on my hg repo, tested with hgperf:
Before:
! wall 23.442445 comb 23.440000 user 23.250000 sys 0.190000 (best of 3)

After:
! wall 20.272187 comb 20.270000 user 20.190000 sys 0.080000 (best of 3)

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -656,21 +656,23 @@  class cg1packer(object):
         # Callback for the manifest, used to collect linkrevs for filelog
         # revisions.
         # Returns the linkrev node (collected in lookupcl).
-        def lookupmflinknode(x):
-            """Callback for looking up the linknode for manifests.
+        if fastpathlinkrev:
+            lookupmflinknode = mfs.__getitem__
+        else:
+            def lookupmflinknode(x):
+                """Callback for looking up the linknode for manifests.
 
-            Returns the linkrev node for the specified manifest.
+                Returns the linkrev node for the specified manifest.
 
-            SIDE EFFECT:
+                SIDE EFFECT:
 
-              fclnodes gets populated with the list of relevant
-              file nodes if we're not using fastpathlinkrev.
+                  fclnodes gets populated with the list of relevant
+                  file nodes.
 
-            Note that this means you can't trust fclnodes until
-            after manifests have been sent to the client.
-            """
-            clnode = mfs[x]
-            if not fastpathlinkrev:
+                Note that this means you can't trust fclnodes until
+                after manifests have been sent to the client.
+                """
+                clnode = mfs[x]
                 mdata = ml.readfast(x)
                 for f in mfchangedfiles[x]:
                     try:
@@ -683,7 +685,7 @@  class cg1packer(object):
                     fclnode = fclnodes.setdefault(n, clnode)
                     if clrevorder[clnode] < clrevorder[fclnode]:
                         fclnodes[n] = clnode
-            return clnode
+                return clnode
 
         mfnodes = self.prune(ml, mfs, commonrevs)
         for x in self._packmanifests(mfnodes, lookupmflinknode):