Mercurial > hg
comparison mercurial/bundle2.py @ 21625:511f5fa63aa2
bundle2: enforce all parameters in a part to be handled
Once we picked a handler, we check that all mandatory parameter keys are
properly supported. If not we raise an exception.
We added a test for this case.
The code now fails for any part with unknown mandatory parameters. We will
ignore such errors for advisory parts in a later changeset.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 27 May 2014 12:01:00 -0700 |
parents | d61066d787c8 |
children | 985d139c8e8f |
comparison
equal
deleted
inserted
replaced
21624:d61066d787c8 | 21625:511f5fa63aa2 |
---|---|
303 raise error.BundleValueError(parttype=key) | 303 raise error.BundleValueError(parttype=key) |
304 op.ui.debug('ignoring unknown advisory part %r\n' % key) | 304 op.ui.debug('ignoring unknown advisory part %r\n' % key) |
305 # consuming the part | 305 # consuming the part |
306 part.read() | 306 part.read() |
307 continue | 307 continue |
308 | |
309 unknownparams = part.mandatorykeys - handler.params | |
310 if unknownparams: | |
311 unknownparams = list(unknownparams) | |
312 unknownparams.sort() | |
313 raise error.BundleValueError(parttype=key, params=unknownparams) | |
308 | 314 |
309 # handler is called outside the above try block so that we don't | 315 # handler is called outside the above try block so that we don't |
310 # risk catching KeyErrors from anything other than the | 316 # risk catching KeyErrors from anything other than the |
311 # parthandlermapping lookup (any KeyError raised by handler() | 317 # parthandlermapping lookup (any KeyError raised by handler() |
312 # itself represents a defect of a different variety). | 318 # itself represents a defect of a different variety). |