Show More
@@ -543,6 +543,7 b' class unbundlepart(unpackermixin):' | |||||
543 | self.ui = ui |
|
543 | self.ui = ui | |
544 | # unbundle state attr |
|
544 | # unbundle state attr | |
545 | self._headerdata = header |
|
545 | self._headerdata = header | |
|
546 | self._headeroffset = 0 | |||
546 | # part data |
|
547 | # part data | |
547 | self.id = None |
|
548 | self.id = None | |
548 | self.type = None |
|
549 | self.type = None | |
@@ -551,26 +552,25 b' class unbundlepart(unpackermixin):' | |||||
551 | self.data = None |
|
552 | self.data = None | |
552 | self._readdata() |
|
553 | self._readdata() | |
553 |
|
554 | |||
|
555 | def _fromheader(self, size): | |||
|
556 | """return the next <size> byte from the header""" | |||
|
557 | offset = self._headeroffset | |||
|
558 | data = self._headerdata[offset:(offset + size)] | |||
|
559 | self._headeroffset += size | |||
|
560 | return data | |||
|
561 | ||||
554 | def _readdata(self): |
|
562 | def _readdata(self): | |
555 | """read the header and setup the object""" |
|
563 | """read the header and setup the object""" | |
556 | # some utility to help reading from the header block |
|
564 | # some utility to help reading from the header block | |
557 | headerblock = self._headerdata |
|
|||
558 | self._offset = 0 # layer violation to have something easy to understand |
|
|||
559 | def fromheader(size): |
|
|||
560 | """return the next <size> byte from the header""" |
|
|||
561 | offset = self._offset |
|
|||
562 | data = headerblock[offset:(offset + size)] |
|
|||
563 | self._offset = offset + size |
|
|||
564 | return data |
|
|||
565 | def unpackheader(format): |
|
565 | def unpackheader(format): | |
566 | """read given format from header |
|
566 | """read given format from header | |
567 |
|
567 | |||
568 | This automatically compute the size of the format to read.""" |
|
568 | This automatically compute the size of the format to read.""" | |
569 | data = fromheader(struct.calcsize(format)) |
|
569 | data = self._fromheader(struct.calcsize(format)) | |
570 | return _unpack(format, data) |
|
570 | return _unpack(format, data) | |
571 |
|
571 | |||
572 | typesize = unpackheader(_fparttypesize)[0] |
|
572 | typesize = unpackheader(_fparttypesize)[0] | |
573 | self.type = fromheader(typesize) |
|
573 | self.type = self._fromheader(typesize) | |
574 | self.ui.debug('part type: "%s"\n' % self.type) |
|
574 | self.ui.debug('part type: "%s"\n' % self.type) | |
575 | self.id = unpackheader(_fpartid)[0] |
|
575 | self.id = unpackheader(_fpartid)[0] | |
576 | self.ui.debug('part id: "%s"\n' % self.id) |
|
576 | self.ui.debug('part id: "%s"\n' % self.id) | |
@@ -588,11 +588,10 b' class unbundlepart(unpackermixin):' | |||||
588 | # retrive param value |
|
588 | # retrive param value | |
589 | manparams = [] |
|
589 | manparams = [] | |
590 | for key, value in mansizes: |
|
590 | for key, value in mansizes: | |
591 | manparams.append((fromheader(key), fromheader(value))) |
|
591 | manparams.append((self._fromheader(key), self._fromheader(value))) | |
592 | advparams = [] |
|
592 | advparams = [] | |
593 | for key, value in advsizes: |
|
593 | for key, value in advsizes: | |
594 | advparams.append((fromheader(key), fromheader(value))) |
|
594 | advparams.append((self._fromheader(key), self._fromheader(value))) | |
595 | del self._offset # clean up layer, nobody saw anything. |
|
|||
596 | self.mandatoryparams = manparams |
|
595 | self.mandatoryparams = manparams | |
597 | self.advisoryparams = advparams |
|
596 | self.advisoryparams = advparams | |
598 | ## part payload |
|
597 | ## part payload |
General Comments 0
You need to be logged in to leave comments.
Login now