diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -299,7 +299,7 @@ def processbundle(repo, unbundler, trans if key != parttype: # mandatory parts # todo: # - use a more precise exception - raise error.BundleValueError(key) + raise error.BundleValueError(parttype=key) op.ui.debug('ignoring unknown advisory part %r\n' % key) # consuming the part part.read() @@ -831,7 +831,8 @@ def handlereplycaps(op, inpart): @parthandler('b2x:error:unsupportedcontent') def handlereplycaps(op, inpart): """Used to transmit unknown content error over the wire""" - raise error.BundleValueError(inpart.params['parttype']) + parttype = inpart.params['parttype'] + raise error.BundleValueError(parttype=parttype) @parthandler('b2x:error:pushraced') def handlereplycaps(op, inpart): diff --git a/mercurial/error.py b/mercurial/error.py --- a/mercurial/error.py +++ b/mercurial/error.py @@ -103,7 +103,10 @@ class BundleValueError(ValueError): """error raised when bundle2 cannot be processed Current main usecase is unsupported part types.""" - pass + + def __init__(self, parttype): + self.parttype = parttype + super(BundleValueError, self).__init__(parttype) class ReadOnlyPartError(RuntimeError): """error raised when code tries to alter a part being generated""" diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -806,7 +806,7 @@ def unbundle(repo, proto, heads): except error.BundleValueError, exc: bundler = bundle2.bundle20(repo.ui) errpart = bundler.newpart('B2X:ERROR:UNSUPPORTEDCONTENT') - errpart.addparam('parttype', str(exc)) + errpart.addparam('parttype', exc.parttype) return streamres(bundler.getchunks()) except util.Abort, inst: # The old code we moved used sys.stderr directly.