Patchwork D289: bundle2: seek part back during iteration

login
register
mail settings
Submitter phabricator
Date Aug. 23, 2017, 7:35 p.m.
Message ID <02fe6c801b558ea23b9fb8b55847c42c@localhost.localdomain>
Download mbox | patch
Permalink /patch/23268/
State Not Applicable
Headers show

Comments

phabricator - Aug. 23, 2017, 7:35 p.m.
durham updated this revision to Diff 1216.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D289?vs=659&id=1216

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

AFFECTED FILES
  mercurial/bundle2.py
  mercurial/bundlerepo.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -301,7 +301,6 @@ 
 
             if cgstream is None:
                 raise error.Abort(_('No changegroups found'))
-            cgstream.seek(0)
 
             self.bundle = changegroup.getunbundler(version, cgstream, 'UN')
 
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -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')