comparison mercurial/bundle2.py @ 25484:a5192774e925

bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error The pushkey code is generic and the server side has little context on what the client is trying to achieve. Generating interesting error messages server side would be challenging. Instead we introduce a dedicated exception that carries more data. In particular, it carries the id of the part which failed that will allow clients to display custom error messages depending on the part intent. The processing and transfer-over-the-wire of this exception is to be implemented in coming changesets.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 27 May 2015 23:48:54 -0700
parents 6de96cb31176
children 8cd0159207df
comparison
equal deleted inserted replaced
25483:fb04372d7b38 25484:a5192774e925
1328 if op.reply is not None: 1328 if op.reply is not None:
1329 rpart = op.reply.newpart('reply:pushkey') 1329 rpart = op.reply.newpart('reply:pushkey')
1330 rpart.addparam('in-reply-to', str(inpart.id), mandatory=False) 1330 rpart.addparam('in-reply-to', str(inpart.id), mandatory=False)
1331 rpart.addparam('return', '%i' % ret, mandatory=False) 1331 rpart.addparam('return', '%i' % ret, mandatory=False)
1332 if inpart.mandatory and not ret: 1332 if inpart.mandatory and not ret:
1333 raise util.Abort(_('failed to update value for "%s/%s"') 1333 kwargs = {}
1334 % (namespace, key)) 1334 for key in ('namespace', 'key', 'new', 'old', 'ret'):
1335 if key in inpart.params:
1336 kwargs[key] = inpart.params[key]
1337 raise error.PushkeyFailed(partid=str(inpart.id), **kwargs)
1335 1338
1336 @parthandler('reply:pushkey', ('return', 'in-reply-to')) 1339 @parthandler('reply:pushkey', ('return', 'in-reply-to'))
1337 def handlepushkeyreply(op, inpart): 1340 def handlepushkeyreply(op, inpart):
1338 """retrieve the result of a pushkey request""" 1341 """retrieve the result of a pushkey request"""
1339 ret = int(inpart.params['return']) 1342 ret = int(inpart.params['return'])