Mercurial > hg
diff mercurial/bundle2.py @ 42143:29569f2db929
bundle2: handle compression in _forwardchunks
_forwardchunks is used to compensate for getbundle protocol deficits.
Since it transparently decodes the payload, it also needs to remove the
corresponding compression parameter in case the server decides to send
one. This the wire protocol part of issue 5990.
Differential Revision: https://phab.mercurial-scm.org/D6182
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Tue, 02 Apr 2019 19:48:31 +0200 |
parents | 566daffc607d |
children | a97b12f726e4 |
line wrap: on
line diff
--- a/mercurial/bundle2.py Wed Dec 27 22:05:20 2017 -0800 +++ b/mercurial/bundle2.py Tue Apr 02 19:48:31 2019 +0200 @@ -834,12 +834,21 @@ if paramssize < 0: raise error.BundleValueError('negative bundle param size: %i' % paramssize) - yield _pack(_fstreamparamsize, paramssize) if paramssize: params = self._readexact(paramssize) self._processallparams(params) - yield params - assert self._compengine.bundletype()[1] == 'UN' + # The payload itself is decompressed below, so drop + # the compression parameter passed down to compensate. + outparams = [] + for p in params.split(' '): + k, v = p.split('=', 1) + if k.lower() != 'compression': + outparams.append(p) + outparams = ' '.join(outparams) + yield _pack(_fstreamparamsize, len(outparams)) + yield outparams + else: + yield _pack(_fstreamparamsize, paramssize) # From there, payload might need to be decompressed self._fp = self._compengine.decompressorreader(self._fp) emptycount = 0