Patchwork [5,of,8] changegroup: introduce makelookupmflinknode(dir)

login
register
mail settings
Submitter Martin von Zweigbergk
Date Feb. 23, 2016, 7:52 p.m.
Message ID <85c69fa32772e880d3a6.1456257150@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/13328/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Feb. 23, 2016, 7:52 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1455348375 28800
#      Fri Feb 12 23:26:15 2016 -0800
# Node ID 85c69fa32772e880d3a682e9cc031feaefc2963a
# Parent  9b6f4541e4675ad27d12e0ae8a63957069e88736
changegroup: introduce makelookupmflinknode(dir)

This is another step towards making the manifest generation recurse
along the directory trees. It makes the two calls to _packmanifests()
more similar.

Patch

diff -r 9b6f4541e467 -r 85c69fa32772 mercurial/changegroup.py
--- a/mercurial/changegroup.py	Fri Feb 12 21:21:28 2016 -0800
+++ b/mercurial/changegroup.py	Fri Feb 12 23:26:15 2016 -0800
@@ -761,9 +761,14 @@ 
         # Callback for the manifest, used to collect linkrevs for filelog
         # revisions.
         # Returns the linkrev node (collected in lookupcl).
-        if fastpathlinkrev:
-            lookupmflinknode = mfs.__getitem__
-        else:
+        def makelookupmflinknode(dir):
+            if fastpathlinkrev:
+                assert not dir
+                return mfs.__getitem__
+
+            if dir:
+                return tmfnodes[dir].get
+
             def lookupmflinknode(x):
                 """Callback for looking up the linknode for manifests.
 
@@ -818,15 +823,17 @@ 
                         if clrevorder[clnode] < clrevorder[tmfclnode]:
                             tmfclnodes[n] = clnode
                 return clnode
+            return lookupmflinknode
 
         mfnodes = self.prune(ml, mfs, commonrevs)
         size = 0
-        for x in self._packmanifests('', mfnodes, lookupmflinknode):
+        for x in self._packmanifests('', mfnodes, makelookupmflinknode('')):
             size += len(x)
             yield x
         for dir, nodes in tmfnodes.iteritems():
             prunednodes = self.prune(ml.dirlog(dir), nodes, commonrevs)
-            for x in self._packmanifests(dir, prunednodes, nodes.get):
+            for x in self._packmanifests(dir, prunednodes,
+                                         makelookupmflinknode(dir)):
                 size += len(x)
                 yield x
         self._verbosenote(_('%8.i (manifests)\n') % size)