bundle2: allow to specify unsupported value on error
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 23 Sep 2015 11:55:27 -0700
changeset 26394 e75da738add5
parent 26393 cff70549a959
child 26395 4e7b0bf9f0b1
bundle2: allow to specify unsupported value on error A client may support an argument but not some of its values (eg: coming "compression" parameters). We allow this case to be carried in the exception.
mercurial/error.py
--- a/mercurial/error.py	Wed Sep 23 11:44:52 2015 -0700
+++ b/mercurial/error.py	Wed Sep 23 11:55:27 2015 -0700
@@ -142,15 +142,26 @@
     """error raised when bundle2 cannot be processed"""
 
 class BundleUnknownFeatureError(BundleValueError):
-    def __init__(self, parttype=None, params=()):
+    def __init__(self, parttype=None, params=(), values=()):
         self.parttype = parttype
         self.params = params
+        self.values = values
         if self.parttype is None:
             msg = 'Stream Parameter'
         else:
             msg = parttype
-        if self.params:
-            msg = '%s - %s' % (msg, ', '.join(self.params))
+        entries = self.params
+        if self.params and self.values:
+            assert len(self.params) == len(self.values)
+            entries = []
+            for idx, par in enumerate(self.params):
+                val = self.values[idx]
+                if val is None:
+                    entries.append(val)
+                else:
+                    entries.append("%s=%r" % (par, val))
+        if entries:
+            msg = '%s - %s' % (msg, ', '.join(entries))
         ValueError.__init__(self, msg)
 
 class ReadOnlyPartError(RuntimeError):