Patchwork [3,of,6,V2] bundle2: allow to specify unsupported value on error

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 25, 2015, 10:08 p.m.
Message ID <a13c84d18821eb5c247a.1443218907@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/10647/
State Accepted
Headers show

Comments

Pierre-Yves David - Sept. 25, 2015, 10:08 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1443034527 25200
#      Wed Sep 23 11:55:27 2015 -0700
# Node ID a13c84d18821eb5c247a18c8c79ad49d0b79879b
# Parent  b262f2e5902fd18c317477844f360bf91078e604
bundle2: allow to specify unsupported value on error

A client may supports an argument but not some of its values (eg: coming
"compression" parameters). We allow this case to be carried in the
exception.

Patch

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -136,19 +136,30 @@  class PushRaced(RuntimeError):
 # bundle2 related errors
 class BundleValueError(ValueError):
     """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):
     """error raised when code tries to alter a part being generated"""
     pass