# HG changeset patch # User Matt Mackall # Date 1284768146 18000 # Node ID 7458de933f266bf45de0e4748f08d5a3111d975f # Parent b63f6422d2a758000591cd7a7e64809a4162683c bundle: push chunkbuffer down into decompress We replace the fixup iterator with a file-like object so that uncompressed file streams can be passed end to end through the stack. diff -r b63f6422d2a7 -r 7458de933f26 mercurial/changegroup.py --- a/mercurial/changegroup.py Fri Sep 17 17:03:08 2010 -0500 +++ b/mercurial/changegroup.py Fri Sep 17 19:02:26 2010 -0500 @@ -136,29 +136,36 @@ yield zd.decompress(chunk) else: raise util.Abort("unknown bundle compression '%s'" % alg) - return generator(fh) + return util.chunkbuffer(generator(fh)) class unbundle10(object): def __init__(self, fh, alg): - self._stream = util.chunkbuffer(decompressor(fh, alg)) + self._stream = decompressor(fh, alg) self._type = alg def compressed(self): return self._type != 'UN' def read(self, l): return self._stream.read(l) +class headerlessfixup(object): + def __init__(self, fh, h): + self._h = h + self._fh = fh + def read(self, n): + if self._h: + d, self._h = self._h[:n], self._h[n:] + if len(d) < n: + d += self._fh.read(n - len(d)) + return d + return self._fh.read(n) + def readbundle(fh, fname): header = fh.read(6) if not fname: fname = "stream" if not header.startswith('HG') and header.startswith('\0'): - # headerless bundle, clean things up - def fixup(f, h): - yield h - for x in f: - yield x - fh = fixup(fh, header) + fh = headerlessfixup(fh, header) header = "HG10UN" magic, version, alg = header[0:2], header[2:4], header[4:6]