bundle2: support None parttype in BundleValueError
This will be used for errors at the stream level.
--- a/mercurial/bundle2.py Tue May 27 12:16:45 2014 -0700
+++ b/mercurial/bundle2.py Wed May 28 16:46:58 2014 -0700
@@ -840,7 +840,9 @@
def handlereplycaps(op, inpart):
"""Used to transmit unknown content error over the wire"""
kwargs = {}
- kwargs['parttype'] = inpart.params['parttype']
+ parttype = inpart.params.get('parttype')
+ if parttype is not None:
+ kwargs['parttype'] = parttype
params = inpart.params.get('params')
if params is not None:
kwargs['params'] = params.split('\0')
--- a/mercurial/error.py Tue May 27 12:16:45 2014 -0700
+++ b/mercurial/error.py Wed May 28 16:46:58 2014 -0700
@@ -102,10 +102,13 @@
class BundleValueError(ValueError):
"""error raised when bundle2 cannot be processed"""
- def __init__(self, parttype, params=()):
+ def __init__(self, parttype=None, params=()):
self.parttype = parttype
self.params = params
- msg = parttype
+ if self.parttype is None:
+ msg = 'Stream Parameter'
+ else:
+ msg = parttype
if self.params:
msg = '%s - %s' % (msg, ', '.join(self.params))
super(BundleValueError, self).__init__(msg)
--- a/mercurial/wireproto.py Tue May 27 12:16:45 2014 -0700
+++ b/mercurial/wireproto.py Wed May 28 16:46:58 2014 -0700
@@ -806,7 +806,8 @@
except error.BundleValueError, exc:
bundler = bundle2.bundle20(repo.ui)
errpart = bundler.newpart('B2X:ERROR:UNSUPPORTEDCONTENT')
- errpart.addparam('parttype', exc.parttype)
+ if exc.parttype is not None:
+ errpart.addparam('parttype', exc.parttype)
if exc.params:
errpart.addparam('params', '\0'.join(exc.params))
return streamres(bundler.getchunks())