[PATCH 4 of 5] bundle2: add a UnsupportedPartError
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Wed Oct 15 20:18:30 UTC 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1413368567 25200
# Wed Oct 15 03:22:47 2014 -0700
# Node ID 91c0c243dae1d965bfb159c86445875188b9068a
# Parent 1d12b2282212d332b2e9caebaf7ee9f5b1092033
bundle2: add a UnsupportedPartError
We need the BundleValueError for format error not related to part support. So
we add a specific class for part-support errors.
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -319,19 +319,19 @@ def _processpart(op, part):
# part key are matched lower case
key = parttype.lower()
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)
return # skip to part processing
@@ -536,11 +536,11 @@ class unbundle20(unpackermixin):
# Some logic will be later added here to try to process the option for
# a dict of known parameter.
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):
"""yield all parts contained in the stream"""
# make sure param have been loaded
@@ -890,11 +890,11 @@ def handlereplycaps(op, inpart):
kwargs['parttype'] = parttype
params = inpart.params.get('params')
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):
"""Used to transmit push race error over the wire"""
raise error.ResponseError(_('push failed:'), inpart.params['message'])
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -100,10 +100,11 @@ class PushRaced(RuntimeError):
# bundle2 related errors
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
if self.parttype is None:
msg = 'Stream Parameter'
More information about the Mercurial-devel
mailing list