diff mercurial/bundle2.py @ 25481:6de96cb31176

bundle2: abort when a mandatory pushkey part fails So far, result of a pushkey operation had no consequence on the transaction (beside the change). We makes it respect the 'mandatory' flag of part so that failed pushkey call abort the whole transaction. This will allow rejecting changes (primary target: changesets) regarding phases or bookmark criteria in the future (when we will push such data in a mandatory part). We currently raise an abort error because all clients support it. We'll introduce a more precise error in the next changesets.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 27 May 2015 05:28:40 -0700
parents d29201352af7
children a5192774e925
line wrap: on
line diff
--- a/mercurial/bundle2.py	Wed May 27 05:35:00 2015 -0700
+++ b/mercurial/bundle2.py	Wed May 27 05:28:40 2015 -0700
@@ -1329,6 +1329,9 @@
         rpart = op.reply.newpart('reply:pushkey')
         rpart.addparam('in-reply-to', str(inpart.id), mandatory=False)
         rpart.addparam('return', '%i' % ret, mandatory=False)
+    if inpart.mandatory and not ret:
+        raise util.Abort(_('failed to update value for "%s/%s"')
+                         % (namespace, key))
 
 @parthandler('reply:pushkey', ('return', 'in-reply-to'))
 def handlepushkeyreply(op, inpart):