changegroup: introduce makelookupmflinknode(dir)
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 12 Feb 2016 23:26:15 -0800
changeset 28231 3faba927dd93
parent 28230 0c2a088ffcc5
child 28232 829d369fc5a8
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.
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)