changeset 33888:891118dcd279

bundle2: seek part back during iteration Previously, iterparts would yield the part to users, then consume the part. This changed the part after the user was given it and left it at the end, both of which seem unexpected. Let's seek back to the beginning after we've consumed it. I tried not seeking to the end at all, but that seems important for the overall bundle2 consumption. This is used in a future patch to let us move the bundlerepo bundle2-changegroup-part to be handled entirely within the for loop, instead of having to do a seek back to 0 after the entire loop finishes. Differential Revision: https://phab.mercurial-scm.org/D289
author Durham Goode <durham@fb.com>
date Wed, 23 Aug 2017 12:35:03 -0700
parents 702a26fec3e2
children f672d060a931
files mercurial/bundle2.py mercurial/bundlerepo.py
diffstat 2 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Wed Aug 23 12:34:56 2017 -0700
+++ b/mercurial/bundle2.py	Wed Aug 23 12:35:03 2017 -0700
@@ -828,7 +828,11 @@
         while headerblock is not None:
             part = unbundlepart(self.ui, headerblock, self._fp)
             yield part
+            # Seek to the end of the part to force it's consumption so the next
+            # part can be read. But then seek back to the beginning so the
+            # code consuming this generator has a part that starts at 0.
             part.seek(0, 2)
+            part.seek(0)
             headerblock = self._readpartheader()
         indebug(self.ui, 'end of bundle2 stream')
 
--- a/mercurial/bundlerepo.py	Wed Aug 23 12:34:56 2017 -0700
+++ b/mercurial/bundlerepo.py	Wed Aug 23 12:35:03 2017 -0700
@@ -301,7 +301,6 @@
 
             if cgstream is None:
                 raise error.Abort(_('No changegroups found'))
-            cgstream.seek(0)
 
             self.bundle = changegroup.getunbundler(version, cgstream, 'UN')