diff 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
line wrap: on
line diff
--- a/hglib/client.py	Sun Dec 10 12:37:36 2017 -0500
+++ b/hglib/client.py	Sun Dec 10 12:50:57 2017 -0500
@@ -147,7 +147,10 @@
     def _readchannel(self):
         data = self.server.stdout.read(hgclient.outputfmtsize)
         if not data:
-            self.close()
+            ret, serr = self._close()
+            if ret != 0:
+                raise error.ServerError('server exited with status %d: %s'
+                                        % (ret, serr.strip()))
             raise error.ResponseError('no response received from server')
         channel, length = struct.unpack(hgclient.outputfmt, data)
         if channel in b('IL'):
@@ -271,6 +274,10 @@
             self.close()
             raise
         except error.ServerError:
+            if self.server is None:
+                # server is already closed, hopefully the ServerError
+                # we got has enough information.
+                raise
             ret, serr = self._close()
             raise error.ServerError('server exited with status %d: %s'
                                     % (ret, serr.strip()))