Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/sshrepo.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 | 3c7907dc95ca |
children | d8fa35c28335 |
comparison
equal
deleted
inserted
replaced
15016:871c77e78f5d | 15017:f4522df38c65 |
---|---|
162 def _decompress(self, stream): | 162 def _decompress(self, stream): |
163 return stream | 163 return stream |
164 | 164 |
165 def _recv(self): | 165 def _recv(self): |
166 l = self.pipei.readline() | 166 l = self.pipei.readline() |
167 if l == '\n': | |
168 err = [] | |
169 while True: | |
170 line = self.pipee.readline() | |
171 if line == '-\n': | |
172 break | |
173 err.extend([line]) | |
174 if len(err) > 0: | |
175 # strip the trailing newline added to the last line server-side | |
176 err[-1] = err[-1][:-1] | |
177 self._abort(error.OutOfBandError(*err)) | |
167 self.readerr() | 178 self.readerr() |
168 try: | 179 try: |
169 l = int(l) | 180 l = int(l) |
170 except ValueError: | 181 except ValueError: |
171 self._abort(error.ResponseError(_("unexpected response:"), l)) | 182 self._abort(error.ResponseError(_("unexpected response:"), l)) |