# HG changeset patch # User Pierre-Yves David # Date 1401320818 25200 # Node ID 3e8bcc90f07c8e082270676fdbccb3ff8b06cb5f # Parent 985d139c8e8f5db0b8ff8cdb4a15f92b948b550e bundle2: support None parttype in BundleValueError This will be used for errors at the stream level. diff -r 985d139c8e8f -r 3e8bcc90f07c mercurial/bundle2.py --- 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') diff -r 985d139c8e8f -r 3e8bcc90f07c mercurial/error.py --- 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) diff -r 985d139c8e8f -r 3e8bcc90f07c mercurial/wireproto.py --- 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())