Mercurial > public > mercurial-scm > hg
comparison mercurial/sshserver.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 | a348739da8f0 |
comparison
equal
deleted
inserted
replaced
15016:871c77e78f5d | 15017:f4522df38c65 |
---|---|
80 self.sendresponse(str(rsp.res)) | 80 self.sendresponse(str(rsp.res)) |
81 | 81 |
82 def sendpusherror(self, rsp): | 82 def sendpusherror(self, rsp): |
83 self.sendresponse(rsp.res) | 83 self.sendresponse(rsp.res) |
84 | 84 |
85 def sendooberror(self, rsp): | |
86 self.ui.ferr.write('%s\n-\n' % rsp.message) | |
87 self.ui.ferr.flush() | |
88 self.fout.write('\n') | |
89 self.fout.flush() | |
90 | |
85 def serve_forever(self): | 91 def serve_forever(self): |
86 try: | 92 try: |
87 while self.serve_one(): | 93 while self.serve_one(): |
88 pass | 94 pass |
89 finally: | 95 finally: |
94 handlers = { | 100 handlers = { |
95 str: sendresponse, | 101 str: sendresponse, |
96 wireproto.streamres: sendstream, | 102 wireproto.streamres: sendstream, |
97 wireproto.pushres: sendpushresponse, | 103 wireproto.pushres: sendpushresponse, |
98 wireproto.pusherr: sendpusherror, | 104 wireproto.pusherr: sendpusherror, |
105 wireproto.ooberror: sendooberror, | |
99 } | 106 } |
100 | 107 |
101 def serve_one(self): | 108 def serve_one(self): |
102 cmd = self.fin.readline()[:-1] | 109 cmd = self.fin.readline()[:-1] |
103 if cmd and cmd in wireproto.commands: | 110 if cmd and cmd in wireproto.commands: |