diff mercurial/error.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 4311e78a4609
children 147bd9e238a1
line wrap: on
line diff
--- a/mercurial/error.py	Fri Jun 05 13:31:18 2015 -0700
+++ b/mercurial/error.py	Wed May 27 23:48:54 2015 -0700
@@ -151,6 +151,21 @@
     """error raised when code tries to alter a part being generated"""
     pass
 
+class PushkeyFailed(Abort):
+    """error raised when a pushkey part failed to update a value"""
+
+    def __init__(self, partid, namespace=None, key=None, new=None, old=None,
+                 ret=None):
+        self.partid = partid
+        self.namespace = namespace
+        self.key = key
+        self.new = new
+        self.old = old
+        self.ret = ret
+        # no i18n expected to be processed into a better message
+        Abort.__init__(self, 'failed to update value for "%s/%s"'
+                       % (namespace, key))
+
 class CensoredNodeError(RevlogError):
     """error raised when content verification fails on a censored node