Mercurial > hg
diff mercurial/bundle2.py @ 21626:985d139c8e8f
bundle2: ignore advisory part with unknown parameters
Advisory parts are advisory. If a handler exists but does not support the
proper parameters, we can safely ignore it.
Test has been updated to include this case.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 27 May 2014 12:16:45 -0700 |
parents | 511f5fa63aa2 |
children | 3e8bcc90f07c |
line wrap: on
line diff
--- a/mercurial/bundle2.py Tue May 27 12:01:00 2014 -0700 +++ b/mercurial/bundle2.py Tue May 27 12:16:45 2014 -0700 @@ -294,23 +294,24 @@ # part key are matched lower case key = parttype.lower() try: - handler = parthandlermapping[key] + handler = parthandlermapping.get(key) + if handler is None: + raise error.BundleValueError(parttype=key) op.ui.debug('found a handler for part %r\n' % parttype) - except KeyError: + unknownparams = part.mandatorykeys - handler.params + if unknownparams: + unknownparams = list(unknownparams) + unknownparams.sort() + raise error.BundleValueError(parttype=key, + params=unknownparams) + except error.BundleValueError, exc: if key != parttype: # mandatory parts - # todo: - # - use a more precise exception - raise error.BundleValueError(parttype=key) - op.ui.debug('ignoring unknown advisory part %r\n' % key) + raise + op.ui.debug('ignoring unsupported advisory part %s\n' % exc) # consuming the part part.read() continue - unknownparams = part.mandatorykeys - handler.params - if unknownparams: - unknownparams = list(unknownparams) - unknownparams.sort() - raise error.BundleValueError(parttype=key, params=unknownparams) # handler is called outside the above try block so that we don't # risk catching KeyErrors from anything other than the