Mercurial > hg-stable
changeset 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 | db03ed8cbfa3 |
children | 112f9c73a0e5 |
files | mercurial/bundle2.py |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py Mon Dec 15 15:00:54 2014 -0500 +++ b/mercurial/bundle2.py Fri Dec 12 11:26:56 2014 -0800 @@ -334,7 +334,7 @@ raise error.UnsupportedPartError(parttype=key, params=unknownparams) except error.UnsupportedPartError, exc: - if key != parttype: # mandatory parts + if part.mandatory: # mandatory parts raise op.ui.debug('ignoring unsupported advisory part %s\n' % exc) return # skip to part processing @@ -786,6 +786,7 @@ self.mandatorykeys = () self._payloadstream = None self._readheader() + self._mandatory = None def _fromheader(self, size): """return the next <size> byte from the header""" @@ -818,6 +819,9 @@ self.ui.debug('part type: "%s"\n' % self.type) self.id = self._unpackheader(_fpartid)[0] self.ui.debug('part id: "%s"\n' % self.id) + # extract mandatory bit from type + self.mandatory = (self.type != self.type.lower()) + self.type = self.type.lower() ## reading parameters # param count mancount, advcount = self._unpackheader(_fpartparamcount)