changeset 28232:829d369fc5a8

changegroup: write root manifests and subdir manifests in a single loop This is another step towards making the manifest generation recurse along the directory trees. The loop over 'tmfnodes' now takes the form of a queue. At this point, we only add to the queue twice: we add the root manifests, and, while visiting the root manifest revisions, we add all subdirectory revisions (for treemanifest repos). Thus, any iterations over 'tmfnodes' after the first will not add any items and the "queue" will just keep shrinking.
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 12 Feb 2016 23:30:18 -0800
parents 3faba927dd93
children 9da2283d0c56
files mercurial/changegroup.py
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changegroup.py	Fri Feb 12 23:26:15 2016 -0800
+++ b/mercurial/changegroup.py	Fri Feb 12 23:30:18 2016 -0800
@@ -756,7 +756,7 @@
                           mfchangedfiles, fnodes):
         repo = self._repo
         ml = repo.manifest
-        tmfnodes = {}
+        tmfnodes = {'': mfs}
 
         # Callback for the manifest, used to collect linkrevs for filelog
         # revisions.
@@ -825,17 +825,16 @@
                 return clnode
             return lookupmflinknode
 
-        mfnodes = self.prune(ml, mfs, commonrevs)
         size = 0
-        for x in self._packmanifests('', mfnodes, makelookupmflinknode('')):
-            size += len(x)
-            yield x
-        for dir, nodes in tmfnodes.iteritems():
+        while tmfnodes:
+            dir = min(tmfnodes)
+            nodes = tmfnodes[dir]
             prunednodes = self.prune(ml.dirlog(dir), nodes, commonrevs)
             for x in self._packmanifests(dir, prunednodes,
                                          makelookupmflinknode(dir)):
                 size += len(x)
                 yield x
+            del tmfnodes[dir]
         self._verbosenote(_('%8.i (manifests)\n') % size)
         yield self._manifestsdone()