Mercurial > public > mercurial-scm > hg
comparison mercurial/bundle2.py @ 21620:6eaa71b2a3cc
bundle2: introduce a parttype attribute to BundleValueError
We will use the Exception for more that just unknown part type.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 28 May 2014 15:51:19 -0700 |
parents | 292331e906d7 |
children | 457492741007 |
comparison
equal
deleted
inserted
replaced
21619:292331e906d7 | 21620:6eaa71b2a3cc |
---|---|
297 op.ui.debug('found a handler for part %r\n' % parttype) | 297 op.ui.debug('found a handler for part %r\n' % parttype) |
298 except KeyError: | 298 except KeyError: |
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() |
306 continue | 306 continue |
307 | 307 |
829 raise util.Abort(inpart.params['message'], hint=inpart.params.get('hint')) | 829 raise util.Abort(inpart.params['message'], hint=inpart.params.get('hint')) |
830 | 830 |
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): |
838 """Used to transmit push race error over the wire""" | 839 """Used to transmit push race error over the wire""" |
839 raise error.ResponseError(_('push failed:'), inpart.params['message']) | 840 raise error.ResponseError(_('push failed:'), inpart.params['message']) |