changegroup: move manifest chunk emission to generate()
We want to get to a point where we can emit data structures from
deltagroup() and derive the raw changegroup data as late as possible.
Differential Revision: https://phab.mercurial-scm.org/D4209
--- a/mercurial/changegroup.py Wed Aug 08 15:09:12 2018 -0700
+++ b/mercurial/changegroup.py Wed Aug 08 15:14:59 2018 -0700
@@ -871,11 +871,24 @@
fnodes = {} # needed file nodes
size = 0
- for chunk in self.generatemanifests(commonrevs, clrevorder,
- fastpathlinkrev, mfs, fnodes, source,
- clstate['clrevtomanifestrev']):
- size += len(chunk)
- yield chunk
+ it = self.generatemanifests(
+ commonrevs, clrevorder, fastpathlinkrev, mfs, fnodes, source,
+ clstate['clrevtomanifestrev'])
+
+ for dir, chunks in it:
+ if dir:
+ assert self.version == b'03'
+ chunk = _fileheader(dir)
+ size += len(chunk)
+ yield chunk
+
+ for chunk in chunks:
+ size += len(chunk)
+ yield chunk
+
+ close = closechunk()
+ size += len(close)
+ yield close
self._verbosenote(_('%8.i (manifests)\n') % size)
yield self._manifestsend
@@ -1053,11 +1066,6 @@
revs = _sortnodesnormal(store, prunednodes,
self._reorder)
- if dir:
- assert self.version == b'03'
- chunk = _fileheader(dir)
- yield chunk
-
it = deltagroup(
self._repo, revs, store, False, lookupfn,
self._deltaparentfn, self._builddeltaheader,
@@ -1067,11 +1075,7 @@
fullclnodes=self._fullclnodes,
precomputedellipsis=self._precomputedellipsis)
- for chunk in it:
- yield chunk
-
- close = closechunk()
- yield close
+ yield dir, it
# The 'source' parameter is useful for extensions
def generatefiles(self, changedfiles, commonrevs, source,