diff 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
line wrap: on
line diff
--- a/mercurial/bundle2.py	Sat Jun 06 00:50:27 2015 -0700
+++ b/mercurial/bundle2.py	Wed Jun 10 13:10:53 2015 -0400
@@ -1109,7 +1109,8 @@
 # These are only the static capabilities.
 # Check the 'getrepocaps' function for the rest.
 capabilities = {'HG20': (),
-                'error': ('abort', 'unsupportedcontent', 'pushraced'),
+                'error': ('abort', 'unsupportedcontent', 'pushraced',
+                          'pushkey'),
                 'listkeys': (),
                 'pushkey': (),
                 'digests': tuple(sorted(util.DIGESTS.keys())),
@@ -1290,6 +1291,17 @@
     """Used to transmit abort error over the wire"""
     raise util.Abort(inpart.params['message'], hint=inpart.params.get('hint'))
 
+@parthandler('error:pushkey', ('namespace', 'key', 'new', 'old', 'ret',
+                               'in-reply-to'))
+def handleerrorpushkey(op, inpart):
+    """Used to transmit failure of a mandatory pushkey over the wire"""
+    kwargs = {}
+    for name in ('namespace', 'key', 'new', 'old', 'ret'):
+        value = inpart.params.get(name)
+        if value is not None:
+            kwargs[name] = value
+    raise error.PushkeyFailed(inpart.params['in-reply-to'], **kwargs)
+
 @parthandler('error:unsupportedcontent', ('parttype', 'params'))
 def handleerrorunsupportedcontent(op, inpart):
     """Used to transmit unknown content error over the wire"""