[PATCH 07 of 11] util: remove decompressors dict (API)

Gregory Szorc gregory.szorc at gmail.com
Tue Nov 1 20:08:40 EDT 2016


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1477159113 25200
#      Sat Oct 22 10:58:33 2016 -0700
# Node ID 289da69280d95f1b983fdf9216739411a9953fb6
# Parent  86eced535f53fc2992c44eef2ecd6231d3c7f33c
util: remove decompressors dict (API)

All in-tree consumers are now using the compressionengines registrar.
Everyone else should switch to it as well.

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2992,34 +2992,10 @@ class _noopengine(object):
     def compressorobj(self):
         return nocompress()
 
     def decompressorreader(self, fh):
         return fh
 
 compressionengines.register('none', _noopengine())
 
-def _makedecompressor(decompcls):
-    def generator(f):
-        d = decompcls()
-        for chunk in filechunkiter(f):
-            yield d.decompress(chunk)
-    def func(fh):
-        return chunkbuffer(generator(fh))
-    return func
-
-def _bz2():
-    d = bz2.BZ2Decompressor()
-    # Bzip2 stream start with BZ, but we stripped it.
-    # we put it back for good measure.
-    d.decompress('BZ')
-    return d
-
-decompressors = {None: lambda fh: fh,
-                 '_truncatedBZ': _makedecompressor(_bz2),
-                 'BZ': _makedecompressor(lambda: bz2.BZ2Decompressor()),
-                 'GZ': _makedecompressor(lambda: zlib.decompressobj()),
-                 }
-# also support the old form by courtesies
-decompressors['UN'] = decompressors[None]
-
 # convenient shortcut
 dst = debugstacktrace


More information about the Mercurial-devel mailing list