Mercurial > hg-stable
changeset 24034:9881a1437799
bundle2.unbundlepart: raise payloadchunks from a closure to a method
In a future patch, seek() will need to make a new chunk iterator for
the stream; this places it somewhere it can be called multiple times.
author | Eric Sumner <ericsumner@fb.com> |
---|---|
date | Wed, 14 Jan 2015 14:32:22 -0800 |
parents | ed5e8a9598ce |
children | 7eb26415bef6 |
files | mercurial/bundle2.py |
diffstat | 1 files changed, 17 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py Fri Jan 23 17:06:03 2015 -0800 +++ b/mercurial/bundle2.py Wed Jan 14 14:32:22 2015 -0800 @@ -852,6 +852,22 @@ self.params.update(dict(self.advisoryparams)) self.mandatorykeys = frozenset(p[0] for p in mandatoryparams) + def _payloadchunks(self): + payloadsize = self._unpack(_fpayloadsize)[0] + self.ui.debug('payload chunk size: %i\n' % payloadsize) + while payloadsize: + if payloadsize == flaginterrupt: + # interruption detection, the handler will now read a + # single part and process it. + interrupthandler(self.ui, self._fp)() + elif payloadsize < 0: + msg = 'negative payload chunk size: %i' % payloadsize + raise error.BundleValueError(msg) + else: + yield self._readexact(payloadsize) + payloadsize = self._unpack(_fpayloadsize)[0] + self.ui.debug('payload chunk size: %i\n' % payloadsize) + def _readheader(self): """read the header and setup the object""" typesize = self._unpackheader(_fparttypesize)[0] @@ -883,22 +899,7 @@ advparams.append((self._fromheader(key), self._fromheader(value))) self._initparams(manparams, advparams) ## part payload - def payloadchunks(): - payloadsize = self._unpack(_fpayloadsize)[0] - self.ui.debug('payload chunk size: %i\n' % payloadsize) - while payloadsize: - if payloadsize == flaginterrupt: - # interruption detection, the handler will now read a - # single part and process it. - interrupthandler(self.ui, self._fp)() - elif payloadsize < 0: - msg = 'negative payload chunk size: %i' % payloadsize - raise error.BundleValueError(msg) - else: - yield self._readexact(payloadsize) - payloadsize = self._unpack(_fpayloadsize)[0] - self.ui.debug('payload chunk size: %i\n' % payloadsize) - self._payloadstream = util.chunkbuffer(payloadchunks()) + self._payloadstream = util.chunkbuffer(self._payloadchunks()) # we read the data, tell it self._initialized = True