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.
--- 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()