Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
42142:5382d8f8530b | 42143:29569f2db929 |
---|---|
832 assert 'params' not in vars(self) | 832 assert 'params' not in vars(self) |
833 paramssize = self._unpack(_fstreamparamsize)[0] | 833 paramssize = self._unpack(_fstreamparamsize)[0] |
834 if paramssize < 0: | 834 if paramssize < 0: |
835 raise error.BundleValueError('negative bundle param size: %i' | 835 raise error.BundleValueError('negative bundle param size: %i' |
836 % paramssize) | 836 % paramssize) |
837 yield _pack(_fstreamparamsize, paramssize) | |
838 if paramssize: | 837 if paramssize: |
839 params = self._readexact(paramssize) | 838 params = self._readexact(paramssize) |
840 self._processallparams(params) | 839 self._processallparams(params) |
841 yield params | 840 # The payload itself is decompressed below, so drop |
842 assert self._compengine.bundletype()[1] == 'UN' | 841 # the compression parameter passed down to compensate. |
842 outparams = [] | |
843 for p in params.split(' '): | |
844 k, v = p.split('=', 1) | |
845 if k.lower() != 'compression': | |
846 outparams.append(p) | |
847 outparams = ' '.join(outparams) | |
848 yield _pack(_fstreamparamsize, len(outparams)) | |
849 yield outparams | |
850 else: | |
851 yield _pack(_fstreamparamsize, paramssize) | |
843 # From there, payload might need to be decompressed | 852 # From there, payload might need to be decompressed |
844 self._fp = self._compengine.decompressorreader(self._fp) | 853 self._fp = self._compengine.decompressorreader(self._fp) |
845 emptycount = 0 | 854 emptycount = 0 |
846 while emptycount < 2: | 855 while emptycount < 2: |
847 # so we can brainlessly loop | 856 # so we can brainlessly loop |