[PATCH 1 of 6] changegroup: use a different compression key for BZ in HG10
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Thu Sep 24 01:21:20 UTC 2015
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1443033210 25200
# Wed Sep 23 11:33:30 2015 -0700
# Node ID 0e8207361f5a0eb27fd92288c34c5bb3d1d3eb53
# Parent f946c1260035f96aa30052c28e6c68c559677059
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 --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -161,10 +161,12 @@ class cg1unpacker(object):
if alg == 'UN':
alg = None # get more modern without breaking too much
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
def compressed(self):
return self._type is not None
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2373,10 +2373,12 @@ def _bz2():
d.decompress('BZ')
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
decompressors['UN'] = decompressors[None]
More information about the Mercurial-devel
mailing list