Mercurial > hg-stable
changeset 30367:5925bda42dbd
bundle2: use compressstream compression engine API
Compression engines now have an API for compressing a stream of
chunks. Switch to it and make low-level compression code disappear.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 07 Nov 2016 18:46:37 -0800 |
parents | c86109eface7 |
children | 38130a0bbb99 |
files | mercurial/bundle2.py |
diffstat | 1 files changed, 4 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py Mon Nov 07 18:57:07 2016 -0800 +++ b/mercurial/bundle2.py Mon Nov 07 18:46:37 2016 -0800 @@ -571,13 +571,8 @@ yield _pack(_fstreamparamsize, len(param)) if param: yield param - # starting compression - compressor = self._compengine.compressorobj() - for chunk in self._getcorechunk(): - data = compressor.compress(chunk) - if data: - yield data - yield compressor.flush() + for chunk in self._compengine.compressstream(self._getcorechunk()): + yield chunk def _paramchunk(self): """return a encoded version of all stream parameters""" @@ -1323,15 +1318,10 @@ raise error.Abort(_('unknown stream compression type: %s') % comp) compengine = util.compengines.forbundletype(comp) - compressor = compengine.compressorobj() - subchunkiter = cg.getchunks() def chunkiter(): yield header - for chunk in subchunkiter: - data = compressor.compress(chunk) - if data: - yield data - yield compressor.flush() + for chunk in compengine.compressstream(cg.getchunks()): + yield chunk chunkiter = chunkiter() # parse the changegroup data, otherwise we will block