D4209: changegroup: move manifest chunk emission to generate()

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Thu Aug 9 20:53:08 UTC 2018


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D4209

AFFECTED FILES
  mercurial/changegroup.py

CHANGE DETAILS

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -872,11 +872,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
@@ -1054,11 +1067,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,
@@ -1068,11 +1076,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,



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list