diff mercurial/wireproto.py @ 15017:f4522df38c65

wireproto: add out-of-band error class to allow remote repo to report errors Older clients will still print the provided error message and not much else: over ssh, this will be each line prefixed with 'remote: ' in addition to an "abort: unexpected response: '\n'"; over http, this will be the '---%<---' banners in addition to the 'does not appear to be a repository' message. Currently, clients with this patch will display 'abort: remote error:\n' and the provided error text, but it is trivial to style the error text however is deemed appropriate.
author Andrew Pritchard <andrewp@fogcreek.com>
date Tue, 02 Aug 2011 15:21:10 -0400
parents 592e45b7d43e
children 42d0d4f63bf0
line wrap: on
line diff
--- a/mercurial/wireproto.py	Wed Aug 03 16:41:14 2011 -0500
+++ b/mercurial/wireproto.py	Tue Aug 02 15:21:10 2011 -0400
@@ -335,6 +335,10 @@
     def __init__(self, res):
         self.res = res
 
+class ooberror(object):
+    def __init__(self, message):
+        self.message = message
+
 def dispatch(repo, proto, command):
     func, spec = commands[command]
     args = proto.getargs(spec)
@@ -376,6 +380,8 @@
             result = func(repo, proto, *[data[k] for k in keys])
         else:
             result = func(repo, proto)
+        if isinstance(result, ooberror):
+            return result
         res.append(escapearg(result))
     return ';'.join(res)