##// END OF EJS Templates
bundle2: introduce a parttype attribute to BundleValueError...
Pierre-Yves David -
r21620:6eaa71b2 default
parent child Browse files
Show More
@@ -299,7 +299,7 b' def processbundle(repo, unbundler, trans'
299 if key != parttype: # mandatory parts
299 if key != parttype: # mandatory parts
300 # todo:
300 # todo:
301 # - use a more precise exception
301 # - use a more precise exception
302 raise error.BundleValueError(key)
302 raise error.BundleValueError(parttype=key)
303 op.ui.debug('ignoring unknown advisory part %r\n' % key)
303 op.ui.debug('ignoring unknown advisory part %r\n' % key)
304 # consuming the part
304 # consuming the part
305 part.read()
305 part.read()
@@ -831,7 +831,8 b' def handlereplycaps(op, inpart):'
831 @parthandler('b2x:error:unsupportedcontent')
831 @parthandler('b2x:error:unsupportedcontent')
832 def handlereplycaps(op, inpart):
832 def handlereplycaps(op, inpart):
833 """Used to transmit unknown content error over the wire"""
833 """Used to transmit unknown content error over the wire"""
834 raise error.BundleValueError(inpart.params['parttype'])
834 parttype = inpart.params['parttype']
835 raise error.BundleValueError(parttype=parttype)
835
836
836 @parthandler('b2x:error:pushraced')
837 @parthandler('b2x:error:pushraced')
837 def handlereplycaps(op, inpart):
838 def handlereplycaps(op, inpart):
@@ -103,7 +103,10 b' class BundleValueError(ValueError):'
103 """error raised when bundle2 cannot be processed
103 """error raised when bundle2 cannot be processed
104
104
105 Current main usecase is unsupported part types."""
105 Current main usecase is unsupported part types."""
106 pass
106
107 def __init__(self, parttype):
108 self.parttype = parttype
109 super(BundleValueError, self).__init__(parttype)
107
110
108 class ReadOnlyPartError(RuntimeError):
111 class ReadOnlyPartError(RuntimeError):
109 """error raised when code tries to alter a part being generated"""
112 """error raised when code tries to alter a part being generated"""
@@ -806,7 +806,7 b' def unbundle(repo, proto, heads):'
806 except error.BundleValueError, exc:
806 except error.BundleValueError, exc:
807 bundler = bundle2.bundle20(repo.ui)
807 bundler = bundle2.bundle20(repo.ui)
808 errpart = bundler.newpart('B2X:ERROR:UNSUPPORTEDCONTENT')
808 errpart = bundler.newpart('B2X:ERROR:UNSUPPORTEDCONTENT')
809 errpart.addparam('parttype', str(exc))
809 errpart.addparam('parttype', exc.parttype)
810 return streamres(bundler.getchunks())
810 return streamres(bundler.getchunks())
811 except util.Abort, inst:
811 except util.Abort, inst:
812 # The old code we moved used sys.stderr directly.
812 # The old code we moved used sys.stderr directly.
General Comments 0
You need to be logged in to leave comments. Login now