changeset 39012:c921ad9cae08

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
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 08 Aug 2018 15:14:59 -0700
parents 2ebdd265fe8c
children c4a2d19d393a
files mercurial/changegroup.py
diffstat 1 files changed, 19 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- 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,