Mercurial > hg
comparison mercurial/bundle2.py @ 23585:94b25d71dd0f
bundle2.unbundlepart: decouple mandatory from parttype
Encoding whether or not a part is mandatory in the capitalization of the
parttype is unintuitive and error-prone. This sequence of patches separates
these concerns in the API to reduce programmer error and pave the way for
a potential change in how this information is transmitted over the wire.
This patch separates the two pieces of information when reading the part header
so that it's unnecessary to know how they were combined during transmission.
author | Eric Sumner <ericsumner@fb.com> |
---|---|
date | Fri, 12 Dec 2014 11:26:56 -0800 |
parents | 743736fc7c41 |
children | 112f9c73a0e5 |
comparison
equal
deleted
inserted
replaced
23584:db03ed8cbfa3 | 23585:94b25d71dd0f |
---|---|
332 unknownparams = list(unknownparams) | 332 unknownparams = list(unknownparams) |
333 unknownparams.sort() | 333 unknownparams.sort() |
334 raise error.UnsupportedPartError(parttype=key, | 334 raise error.UnsupportedPartError(parttype=key, |
335 params=unknownparams) | 335 params=unknownparams) |
336 except error.UnsupportedPartError, exc: | 336 except error.UnsupportedPartError, exc: |
337 if key != parttype: # mandatory parts | 337 if part.mandatory: # mandatory parts |
338 raise | 338 raise |
339 op.ui.debug('ignoring unsupported advisory part %s\n' % exc) | 339 op.ui.debug('ignoring unsupported advisory part %s\n' % exc) |
340 return # skip to part processing | 340 return # skip to part processing |
341 | 341 |
342 # handler is called outside the above try block so that we don't | 342 # handler is called outside the above try block so that we don't |
784 self.advisoryparams = None | 784 self.advisoryparams = None |
785 self.params = None | 785 self.params = None |
786 self.mandatorykeys = () | 786 self.mandatorykeys = () |
787 self._payloadstream = None | 787 self._payloadstream = None |
788 self._readheader() | 788 self._readheader() |
789 self._mandatory = None | |
789 | 790 |
790 def _fromheader(self, size): | 791 def _fromheader(self, size): |
791 """return the next <size> byte from the header""" | 792 """return the next <size> byte from the header""" |
792 offset = self._headeroffset | 793 offset = self._headeroffset |
793 data = self._headerdata[offset:(offset + size)] | 794 data = self._headerdata[offset:(offset + size)] |
816 typesize = self._unpackheader(_fparttypesize)[0] | 817 typesize = self._unpackheader(_fparttypesize)[0] |
817 self.type = self._fromheader(typesize) | 818 self.type = self._fromheader(typesize) |
818 self.ui.debug('part type: "%s"\n' % self.type) | 819 self.ui.debug('part type: "%s"\n' % self.type) |
819 self.id = self._unpackheader(_fpartid)[0] | 820 self.id = self._unpackheader(_fpartid)[0] |
820 self.ui.debug('part id: "%s"\n' % self.id) | 821 self.ui.debug('part id: "%s"\n' % self.id) |
822 # extract mandatory bit from type | |
823 self.mandatory = (self.type != self.type.lower()) | |
824 self.type = self.type.lower() | |
821 ## reading parameters | 825 ## reading parameters |
822 # param count | 826 # param count |
823 mancount, advcount = self._unpackheader(_fpartparamcount) | 827 mancount, advcount = self._unpackheader(_fpartparamcount) |
824 self.ui.debug('part parameters: %i\n' % (mancount + advcount)) | 828 self.ui.debug('part parameters: %i\n' % (mancount + advcount)) |
825 # param size | 829 # param size |