# HG changeset patch # User Pierre-Yves David # Date 1443033210 25200 # Node ID 127b59787fd5de875478aea2e55820f2521b77d5 # Parent f206543d838079a5af9bdbe2f4677af2f3bae649 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". diff -r f206543d8380 -r 127b59787fd5 mercurial/changegroup.py --- 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 diff -r f206543d8380 -r 127b59787fd5 mercurial/util.py --- 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