Patchwork [05,of,10,V2] changegroup: use compression engines API

login
register
mail settings
Submitter Gregory Szorc
Date Nov. 8, 2016, 3:13 a.m.
Message ID <5642a2b769a73befd6c3.1478574833@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/17384/
State Accepted
Headers show

Comments

Gregory Szorc - Nov. 8, 2016, 3:13 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1478572693 28800
#      Mon Nov 07 18:38:13 2016 -0800
# Node ID 5642a2b769a73befd6c3e3539e7e373a20392f3a
# Parent  439b96dc6e896d9875ae24fae4a59e41b00b63c6
changegroup: use compression engines API

The new API doesn't have the equivalence for None and 'UN' so we
introduce code to use 'UN' explicitly.

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -137,14 +137,16 @@  class cg1unpacker(object):
     _grouplistcount = 1 # One list of files after the manifests
 
     def __init__(self, fh, alg, extras=None):
-        if alg == 'UN':
-            alg = None # get more modern without breaking too much
-        if not alg in util.decompressors:
+        if alg is None:
+            alg = 'UN'
+        if alg not in util.compengines.supportedbundletypes:
             raise error.Abort(_('unknown stream compression type: %s')
                              % alg)
         if alg == 'BZ':
             alg = '_truncatedBZ'
-        self._stream = util.decompressors[alg](fh)
+
+        compengine = util.compengines.forbundletype(alg)
+        self._stream = compengine.decompressorreader(fh)
         self._type = alg
         self.extras = extras or {}
         self.callback = None