diff mercurial/hgweb/protocol.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 afccc64eea73
children 6c2563b2c1c6
line wrap: on
line diff
--- a/mercurial/hgweb/protocol.py	Wed Aug 03 16:41:14 2011 -0500
+++ b/mercurial/hgweb/protocol.py	Tue Aug 02 15:21:10 2011 -0400
@@ -10,6 +10,7 @@
 from common import HTTP_OK
 
 HGTYPE = 'application/mercurial-0.1'
+HGERRTYPE = 'application/hg-error'
 
 class webproto(object):
     def __init__(self, req, ui):
@@ -90,3 +91,7 @@
         rsp = '0\n%s\n' % rsp.res
         req.respond(HTTP_OK, HGTYPE, length=len(rsp))
         return [rsp]
+    elif isinstance(rsp, wireproto.ooberror):
+        rsp = rsp.message
+        req.respond(HTTP_OK, HGERRTYPE, length=len(rsp))
+        return [rsp]