D4210: changegroup: move file chunk emission to generate()

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


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

REVISION SUMMARY
  Same deal as manifests. 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/D4210

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
@@ -902,10 +902,24 @@
         mfs.clear()
         clrevs = set(cl.rev(x) for x in clnodes)
 
-        for chunk in self.generatefiles(changedfiles, commonrevs,
-                                        source, mfdicts, fastpathlinkrev,
-                                        fnodes, clrevs):
-            yield chunk
+        it = self.generatefiles(changedfiles, commonrevs,
+                                source, mfdicts, fastpathlinkrev,
+                                fnodes, clrevs)
+
+        for path, chunks in it:
+            h = _fileheader(path)
+            size = len(h)
+            yield h
+
+            for chunk in chunks:
+                size += len(chunk)
+                yield chunk
+
+            close = closechunk()
+            size += len(close)
+            yield close
+
+            self._verbosenote(_('%8.i  %s\n') % (size, path))
 
         yield closechunk()
 
@@ -1158,9 +1172,6 @@
                                             self._reorder)
 
                 progress.update(i + 1, item=fname)
-                h = _fileheader(fname)
-                size = len(h)
-                yield h
 
                 it = deltagroup(
                     self._repo, revs, filerevlog, False, lookupfilelog,
@@ -1170,15 +1181,8 @@
                     fullclnodes=self._fullclnodes,
                     precomputedellipsis=self._precomputedellipsis)
 
-                for chunk in it:
-                    size += len(chunk)
-                    yield chunk
+                yield fname, it
 
-                close = closechunk()
-                size += len(close)
-                yield close
-
-                self._verbosenote(_('%8.i  %s\n') % (size, fname))
         progress.complete()
 
 def _deltaparentprev(store, rev, p1, p2, prev):



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


More information about the Mercurial-devel mailing list