comparison mercurial/error.py @ 26394:e75da738add5

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 23 Sep 2015 11:55:27 -0700
parents cff70549a959
children 024644b1900b
comparison
equal deleted inserted replaced
26393:cff70549a959 26394:e75da738add5
140 # bundle2 related errors 140 # bundle2 related errors
141 class BundleValueError(ValueError): 141 class BundleValueError(ValueError):
142 """error raised when bundle2 cannot be processed""" 142 """error raised when bundle2 cannot be processed"""
143 143
144 class BundleUnknownFeatureError(BundleValueError): 144 class BundleUnknownFeatureError(BundleValueError):
145 def __init__(self, parttype=None, params=()): 145 def __init__(self, parttype=None, params=(), values=()):
146 self.parttype = parttype 146 self.parttype = parttype
147 self.params = params 147 self.params = params
148 self.values = values
148 if self.parttype is None: 149 if self.parttype is None:
149 msg = 'Stream Parameter' 150 msg = 'Stream Parameter'
150 else: 151 else:
151 msg = parttype 152 msg = parttype
152 if self.params: 153 entries = self.params
153 msg = '%s - %s' % (msg, ', '.join(self.params)) 154 if self.params and self.values:
155 assert len(self.params) == len(self.values)
156 entries = []
157 for idx, par in enumerate(self.params):
158 val = self.values[idx]
159 if val is None:
160 entries.append(val)
161 else:
162 entries.append("%s=%r" % (par, val))
163 if entries:
164 msg = '%s - %s' % (msg, ', '.join(entries))
154 ValueError.__init__(self, msg) 165 ValueError.__init__(self, msg)
155 166
156 class ReadOnlyPartError(RuntimeError): 167 class ReadOnlyPartError(RuntimeError):
157 """error raised when code tries to alter a part being generated""" 168 """error raised when code tries to alter a part being generated"""
158 pass 169 pass