comparison hglib/client.py @ 196:c586d02f7cda

_readchannel: if a read failure is due to a broken server, report that We can end up in this codepath if the specified hg binary fails to start, and we're better off reporting that than the fact that we got no response.
author Augie Fackler <raf@durin42.com>
date Sun, 10 Dec 2017 12:50:57 -0500
parents 7c37f08d303d
children 6949fc164439
comparison
equal deleted inserted replaced
195:7c37f08d303d 196:c586d02f7cda
145 ", got %r" % msg[1]) 145 ", got %r" % msg[1])
146 146
147 def _readchannel(self): 147 def _readchannel(self):
148 data = self.server.stdout.read(hgclient.outputfmtsize) 148 data = self.server.stdout.read(hgclient.outputfmtsize)
149 if not data: 149 if not data:
150 self.close() 150 ret, serr = self._close()
151 if ret != 0:
152 raise error.ServerError('server exited with status %d: %s'
153 % (ret, serr.strip()))
151 raise error.ResponseError('no response received from server') 154 raise error.ResponseError('no response received from server')
152 channel, length = struct.unpack(hgclient.outputfmt, data) 155 channel, length = struct.unpack(hgclient.outputfmt, data)
153 if channel in b('IL'): 156 if channel in b('IL'):
154 return channel, length 157 return channel, length
155 else: 158 else:
269 self._readhello() 272 self._readhello()
270 except error.ResponseError: 273 except error.ResponseError:
271 self.close() 274 self.close()
272 raise 275 raise
273 except error.ServerError: 276 except error.ServerError:
277 if self.server is None:
278 # server is already closed, hopefully the ServerError
279 # we got has enough information.
280 raise
274 ret, serr = self._close() 281 ret, serr = self._close()
275 raise error.ServerError('server exited with status %d: %s' 282 raise error.ServerError('server exited with status %d: %s'
276 % (ret, serr.strip())) 283 % (ret, serr.strip()))
277 return self 284 return self
278 285