comparison mercurial/util.py @ 30365:c52faa621d9f

util: remove decompressors dict (API) All in-tree consumers are now using the compengines registrar. Extensions should switch to it as well.
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 07 Nov 2016 18:39:08 -0800
parents 75f5beb54e29
children c86109eface7
comparison
equal deleted inserted replaced
30364:a37a96d838b9 30365:c52faa621d9f
3068 def decompressorreader(self, fh): 3068 def decompressorreader(self, fh):
3069 return fh 3069 return fh
3070 3070
3071 compengines.register(_noopengine()) 3071 compengines.register(_noopengine())
3072 3072
3073 def _makedecompressor(decompcls):
3074 def generator(f):
3075 d = decompcls()
3076 for chunk in filechunkiter(f):
3077 yield d.decompress(chunk)
3078 def func(fh):
3079 return chunkbuffer(generator(fh))
3080 return func
3081
3082 def _bz2():
3083 d = bz2.BZ2Decompressor()
3084 # Bzip2 stream start with BZ, but we stripped it.
3085 # we put it back for good measure.
3086 d.decompress('BZ')
3087 return d
3088
3089 decompressors = {None: lambda fh: fh,
3090 '_truncatedBZ': _makedecompressor(_bz2),
3091 'BZ': _makedecompressor(lambda: bz2.BZ2Decompressor()),
3092 'GZ': _makedecompressor(lambda: zlib.decompressobj()),
3093 }
3094 # also support the old form by courtesies
3095 decompressors['UN'] = decompressors[None]
3096
3097 # convenient shortcut 3073 # convenient shortcut
3098 dst = debugstacktrace 3074 dst = debugstacktrace