changeset 26392:127b59787fd5

changegroup: use a different compression key for BZ in HG10 For "space saving", bundle1 "strip" the first two bytes of the BZ stream since they always are 'BZ'. So the current code boostrap the uncompressor with 'BZ'. This hack is impractical in more generic case so we move it in a dedicated "decompression".
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 23 Sep 2015 11:33:30 -0700
parents f206543d8380
children cff70549a959
files mercurial/changegroup.py mercurial/util.py
diffstat 2 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changegroup.py	Sat Sep 26 17:24:12 2015 +0800
+++ b/mercurial/changegroup.py	Wed Sep 23 11:33:30 2015 -0700
@@ -163,6 +163,8 @@
         if not alg in util.decompressors:
             raise util.Abort(_('unknown stream compression type: %s')
                              % alg)
+        if alg == 'BZ':
+            alg = '_truncatedBZ'
         self._stream = util.decompressors[alg](fh)
         self._type = alg
         self.callback = None
--- a/mercurial/util.py	Sat Sep 26 17:24:12 2015 +0800
+++ b/mercurial/util.py	Wed Sep 23 11:33:30 2015 -0700
@@ -2378,7 +2378,8 @@
     return d
 
 decompressors = {None: lambda fh: fh,
-                 'BZ': _makedecompressor(_bz2),
+                 '_truncatedBZ': _makedecompressor(_bz2),
+                 'BZ': _makedecompressor(lambda: bz2.BZ2Decompressor()),
                  'GZ': _makedecompressor(lambda: zlib.decompressobj()),
                  }
 # also support the old form by courtesies