##// END OF EJS Templates
compression: use 'None' for no-compression...
Pierre-Yves David -
r26267:eca468b8 default
parent child Browse files
Show More
@@ -158,6 +158,8 b' class cg1unpacker(object):'
158 deltaheadersize = struct.calcsize(deltaheader)
158 deltaheadersize = struct.calcsize(deltaheader)
159 version = '01'
159 version = '01'
160 def __init__(self, fh, alg):
160 def __init__(self, fh, alg):
161 if alg == 'UN':
162 alg = None # get more modern without breaking too much
161 if not alg in util.decompressors:
163 if not alg in util.decompressors:
162 raise util.Abort(_('unknown stream compression type: %s')
164 raise util.Abort(_('unknown stream compression type: %s')
163 % alg)
165 % alg)
@@ -165,7 +167,7 b' class cg1unpacker(object):'
165 self._type = alg
167 self._type = alg
166 self.callback = None
168 self.callback = None
167 def compressed(self):
169 def compressed(self):
168 return self._type != 'UN'
170 return self._type is not None
169 def read(self, l):
171 def read(self, l):
170 return self._stream.read(l)
172 return self._stream.read(l)
171 def seek(self, pos):
173 def seek(self, pos):
@@ -2349,11 +2349,13 b' class nocompress(object):'
2349 return ""
2349 return ""
2350
2350
2351 compressors = {
2351 compressors = {
2352 'UN': nocompress,
2352 None: nocompress,
2353 # lambda to prevent early import
2353 # lambda to prevent early import
2354 'BZ': lambda: bz2.BZ2Compressor(),
2354 'BZ': lambda: bz2.BZ2Compressor(),
2355 'GZ': lambda: zlib.compressobj(),
2355 'GZ': lambda: zlib.compressobj(),
2356 }
2356 }
2357 # also support the old form by courtesies
2358 compressors['UN'] = compressors[None]
2357
2359
2358 def _makedecompressor(decompcls):
2360 def _makedecompressor(decompcls):
2359 def generator(f):
2361 def generator(f):
@@ -2371,10 +2373,12 b' def _bz2():'
2371 d.decompress('BZ')
2373 d.decompress('BZ')
2372 return d
2374 return d
2373
2375
2374 decompressors = {'UN': lambda fh: fh,
2376 decompressors = {None: lambda fh: fh,
2375 'BZ': _makedecompressor(_bz2),
2377 'BZ': _makedecompressor(_bz2),
2376 'GZ': _makedecompressor(lambda: zlib.decompressobj()),
2378 'GZ': _makedecompressor(lambda: zlib.decompressobj()),
2377 }
2379 }
2380 # also support the old form by courtesies
2381 decompressors['UN'] = decompressors[None]
2378
2382
2379 # convenient shortcut
2383 # convenient shortcut
2380 dst = debugstacktrace
2384 dst = debugstacktrace
General Comments 0
You need to be logged in to leave comments. Login now