Patchwork D1390: bundle2: don't use seekable bundle2 parts by default (issue5691)

login
register
mail settings
Submitter phabricator
Date Nov. 20, 2017, 11:50 p.m.
Message ID <dff60083bf1c8eba46c70c83b4136c82@localhost.localdomain>
Download mbox | patch
Permalink /patch/25695/
State Not Applicable
Headers show

Comments

phabricator - Nov. 20, 2017, 11:50 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGda91e7309daf: bundle2: don&#039;t use seekable bundle2 parts by default (issue5691) (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1390?vs=3468&id=3694

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

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

CHANGE DETAILS




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

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -289,7 +289,7 @@ 
             self._cgunpacker = None
 
             cgpart = None
-            for part in bundle.iterparts():
+            for part in bundle.iterparts(seekable=True):
                 if part.type == 'changegroup':
                     if cgpart:
                         raise NotImplementedError("can't process "
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -845,16 +845,17 @@ 
             yield self._readexact(size)
 
 
-    def iterparts(self):
+    def iterparts(self, seekable=False):
         """yield all parts contained in the stream"""
+        cls = seekableunbundlepart if seekable else unbundlepart
         # make sure param have been loaded
         self.params
         # From there, payload need to be decompressed
         self._fp = self._compengine.decompressorreader(self._fp)
         indebug(self.ui, 'start extraction of bundle2 parts')
         headerblock = self._readpartheader()
         while headerblock is not None:
-            part = seekableunbundlepart(self.ui, headerblock, self._fp)
+            part = cls(self.ui, headerblock, self._fp)
             yield part
             # Ensure part is fully consumed so we can start reading the next
             # part.
@@ -1154,7 +1155,7 @@ 
         if headerblock is None:
             indebug(self.ui, 'no part found during interruption.')
             return
-        part = seekableunbundlepart(self.ui, headerblock, self._fp)
+        part = unbundlepart(self.ui, headerblock, self._fp)
         op = interruptoperation(self.ui)
         hardabort = False
         try:
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -546,8 +546,12 @@ 
         for part in bundle.iterparts():
             pass
 
+    def iterpartsseekable(bundle):
+        for part in bundle.iterparts(seekable=True):
+            pass
+
     def seek(bundle):
-        for part in bundle.iterparts():
+        for part in bundle.iterparts(seekable=True):
             part.seek(0, os.SEEK_END)
 
     def makepartreadnbytes(size):
@@ -583,6 +587,7 @@ 
             benches.extend([
                 (makebench(forwardchunks), 'bundle2 forwardchunks()'),
                 (makebench(iterparts), 'bundle2 iterparts()'),
+                (makebench(iterpartsseekable), 'bundle2 iterparts() seekable'),
                 (makebench(seek), 'bundle2 part seek()'),
                 (makepartreadnbytes(8192), 'bundle2 part read(8k)'),
                 (makepartreadnbytes(16384), 'bundle2 part read(16k)'),