mercurial/bundle2.py
changeset 21626 985d139c8e8f
parent 21625 511f5fa63aa2
child 21627 3e8bcc90f07c
--- 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