comparison mercurial/bundle2.py @ 21611:71b7b3f79a3c

bundle2: use the new ``part.params`` dictionary We use the new ``part.params`` dictionary to access the value of parameters instead of creating one from the part's attributes.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 26 May 2014 18:45:43 -0700
parents d6056805f8f4
children f221eb0531d9
comparison
equal deleted inserted replaced
21610:d6056805f8f4 21611:71b7b3f79a3c
792 part.addparam('return', '%i' % ret, mandatory=False) 792 part.addparam('return', '%i' % ret, mandatory=False)
793 assert not inpart.read() 793 assert not inpart.read()
794 794
795 @parthandler('b2x:reply:changegroup') 795 @parthandler('b2x:reply:changegroup')
796 def handlechangegroup(op, inpart): 796 def handlechangegroup(op, inpart):
797 p = dict(inpart.advisoryparams) 797 ret = int(inpart.params['return'])
798 ret = int(p['return']) 798 replyto = int(inpart.params['in-reply-to'])
799 op.records.add('changegroup', {'return': ret}, int(p['in-reply-to'])) 799 op.records.add('changegroup', {'return': ret}, replyto)
800 800
801 @parthandler('b2x:check:heads') 801 @parthandler('b2x:check:heads')
802 def handlechangegroup(op, inpart): 802 def handlechangegroup(op, inpart):
803 """check that head of the repo did not change 803 """check that head of the repo did not change
804 804
830 op.reply = bundle20(op.ui, caps) 830 op.reply = bundle20(op.ui, caps)
831 831
832 @parthandler('b2x:error:abort') 832 @parthandler('b2x:error:abort')
833 def handlereplycaps(op, inpart): 833 def handlereplycaps(op, inpart):
834 """Used to transmit abort error over the wire""" 834 """Used to transmit abort error over the wire"""
835 manargs = dict(inpart.mandatoryparams) 835 raise util.Abort(inpart.params['message'], hint=inpart.params.get('hint'))
836 advargs = dict(inpart.advisoryparams)
837 raise util.Abort(manargs['message'], hint=advargs.get('hint'))
838 836
839 @parthandler('b2x:error:unknownpart') 837 @parthandler('b2x:error:unknownpart')
840 def handlereplycaps(op, inpart): 838 def handlereplycaps(op, inpart):
841 """Used to transmit unknown part error over the wire""" 839 """Used to transmit unknown part error over the wire"""
842 manargs = dict(inpart.mandatoryparams) 840 raise UnknownPartError(inpart.params['parttype'])
843 raise UnknownPartError(manargs['parttype'])
844 841
845 @parthandler('b2x:error:pushraced') 842 @parthandler('b2x:error:pushraced')
846 def handlereplycaps(op, inpart): 843 def handlereplycaps(op, inpart):
847 """Used to transmit push race error over the wire""" 844 """Used to transmit push race error over the wire"""
848 manargs = dict(inpart.mandatoryparams) 845 raise error.ResponseError(_('push failed:'), inpart.params['message'])
849 raise error.ResponseError(_('push failed:'), manargs['message'])