comparison mercurial/bundle2.py @ 25493:d8e7b0781ad7

bundle2: convey PushkeyFailed error over the wire We add a way to convey the precise exception. This will allow better error message on the server.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 10 Jun 2015 13:10:53 -0400
parents 219b8ab31220
children 86472038dfd2
comparison
equal deleted inserted replaced
25492:219b8ab31220 25493:d8e7b0781ad7
1107 self._pos = newpos 1107 self._pos = newpos
1108 1108
1109 # These are only the static capabilities. 1109 # These are only the static capabilities.
1110 # Check the 'getrepocaps' function for the rest. 1110 # Check the 'getrepocaps' function for the rest.
1111 capabilities = {'HG20': (), 1111 capabilities = {'HG20': (),
1112 'error': ('abort', 'unsupportedcontent', 'pushraced'), 1112 'error': ('abort', 'unsupportedcontent', 'pushraced',
1113 'pushkey'),
1113 'listkeys': (), 1114 'listkeys': (),
1114 'pushkey': (), 1115 'pushkey': (),
1115 'digests': tuple(sorted(util.DIGESTS.keys())), 1116 'digests': tuple(sorted(util.DIGESTS.keys())),
1116 'remote-changegroup': ('http', 'https'), 1117 'remote-changegroup': ('http', 'https'),
1117 'hgtagsfnodes': (), 1118 'hgtagsfnodes': (),
1288 @parthandler('error:abort', ('message', 'hint')) 1289 @parthandler('error:abort', ('message', 'hint'))
1289 def handleerrorabort(op, inpart): 1290 def handleerrorabort(op, inpart):
1290 """Used to transmit abort error over the wire""" 1291 """Used to transmit abort error over the wire"""
1291 raise util.Abort(inpart.params['message'], hint=inpart.params.get('hint')) 1292 raise util.Abort(inpart.params['message'], hint=inpart.params.get('hint'))
1292 1293
1294 @parthandler('error:pushkey', ('namespace', 'key', 'new', 'old', 'ret',
1295 'in-reply-to'))
1296 def handleerrorpushkey(op, inpart):
1297 """Used to transmit failure of a mandatory pushkey over the wire"""
1298 kwargs = {}
1299 for name in ('namespace', 'key', 'new', 'old', 'ret'):
1300 value = inpart.params.get(name)
1301 if value is not None:
1302 kwargs[name] = value
1303 raise error.PushkeyFailed(inpart.params['in-reply-to'], **kwargs)
1304
1293 @parthandler('error:unsupportedcontent', ('parttype', 'params')) 1305 @parthandler('error:unsupportedcontent', ('parttype', 'params'))
1294 def handleerrorunsupportedcontent(op, inpart): 1306 def handleerrorunsupportedcontent(op, inpart):
1295 """Used to transmit unknown content error over the wire""" 1307 """Used to transmit unknown content error over the wire"""
1296 kwargs = {} 1308 kwargs = {}
1297 parttype = inpart.params.get('parttype') 1309 parttype = inpart.params.get('parttype')