changeset 23010:73f394f4affc

bundle2: add an UnsupportedPartError We need the BundleValueError for format errors not related to part support. So we add a specific class for part-support errors.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 15 Oct 2014 03:22:47 -0700
parents 90f86ad3d4ff
children 006a81d07e57
files mercurial/bundle2.py mercurial/error.py
diffstat 2 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Wed Oct 01 23:40:23 2014 -0500
+++ b/mercurial/bundle2.py	Wed Oct 15 03:22:47 2014 -0700
@@ -321,15 +321,15 @@
         try:
             handler = parthandlermapping.get(key)
             if handler is None:
-                raise error.BundleValueError(parttype=key)
+                raise error.UnsupportedPartError(parttype=key)
             op.ui.debug('found a handler for part %r\n' % parttype)
             unknownparams = part.mandatorykeys - handler.params
             if unknownparams:
                 unknownparams = list(unknownparams)
                 unknownparams.sort()
-                raise error.BundleValueError(parttype=key,
+                raise error.UnsupportedPartError(parttype=key,
                                                params=unknownparams)
-        except error.BundleValueError, exc:
+        except error.UnsupportedPartError, exc:
             if key != parttype: # mandatory parts
                 raise
             op.ui.debug('ignoring unsupported advisory part %s\n' % exc)
@@ -538,7 +538,7 @@
         if name[0].islower():
             self.ui.debug("ignoring unknown parameter %r\n" % name)
         else:
-            raise error.BundleValueError(params=(name,))
+            raise error.UnsupportedPartError(params=(name,))
 
 
     def iterparts(self):
@@ -894,7 +894,7 @@
     if params is not None:
         kwargs['params'] = params.split('\0')
 
-    raise error.BundleValueError(**kwargs)
+    raise error.UnsupportedPartError(**kwargs)
 
 @parthandler('b2x:error:pushraced', ('message',))
 def handlereplycaps(op, inpart):
--- a/mercurial/error.py	Wed Oct 01 23:40:23 2014 -0500
+++ b/mercurial/error.py	Wed Oct 15 03:22:47 2014 -0700
@@ -102,6 +102,7 @@
 class BundleValueError(ValueError):
     """error raised when bundle2 cannot be processed"""
 
+class UnsupportedPartError(BundleValueError):
     def __init__(self, parttype=None, params=()):
         self.parttype = parttype
         self.params = params