Mercurial > public > mercurial-scm > hg
comparison mercurial/bundle2.py @ 23586:112f9c73a0e5
bundle2._processpart: forcing lower-case compare is no longer necessary
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.
Since the parttype and mandatory bit are separated in bundle2.unbundlepart
(see previous patch), there is no longer a need to remove the mandatory bit
before working with the parttype.
author | Eric Sumner <ericsumner@fb.com> |
---|---|
date | Fri, 12 Dec 2014 12:31:41 -0800 |
parents | 94b25d71dd0f |
children | 4440c7cc3728 |
comparison
equal
deleted
inserted
replaced
23585:94b25d71dd0f | 23586:112f9c73a0e5 |
---|---|
317 """process a single part from a bundle | 317 """process a single part from a bundle |
318 | 318 |
319 The part is guaranteed to have been fully consumed when the function exits | 319 The part is guaranteed to have been fully consumed when the function exits |
320 (even if an exception is raised).""" | 320 (even if an exception is raised).""" |
321 try: | 321 try: |
322 parttype = part.type | |
323 # part key are matched lower case | |
324 key = parttype.lower() | |
325 try: | 322 try: |
326 handler = parthandlermapping.get(key) | 323 handler = parthandlermapping.get(part.type) |
327 if handler is None: | 324 if handler is None: |
328 raise error.UnsupportedPartError(parttype=key) | 325 raise error.UnsupportedPartError(parttype=part.type) |
329 op.ui.debug('found a handler for part %r\n' % parttype) | 326 op.ui.debug('found a handler for part %r\n' % part.type) |
330 unknownparams = part.mandatorykeys - handler.params | 327 unknownparams = part.mandatorykeys - handler.params |
331 if unknownparams: | 328 if unknownparams: |
332 unknownparams = list(unknownparams) | 329 unknownparams = list(unknownparams) |
333 unknownparams.sort() | 330 unknownparams.sort() |
334 raise error.UnsupportedPartError(parttype=key, | 331 raise error.UnsupportedPartError(parttype=part.type, |
335 params=unknownparams) | 332 params=unknownparams) |
336 except error.UnsupportedPartError, exc: | 333 except error.UnsupportedPartError, exc: |
337 if part.mandatory: # mandatory parts | 334 if part.mandatory: # mandatory parts |
338 raise | 335 raise |
339 op.ui.debug('ignoring unsupported advisory part %s\n' % exc) | 336 op.ui.debug('ignoring unsupported advisory part %s\n' % exc) |