[PATCH 2 of 3 hglib] _readchannel: if a read failure is due to a broken server, report that

Augie Fackler raf at durin42.com
Sun Dec 10 12:54:53 EST 2017


# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1512928257 18000
#      Sun Dec 10 12:50:57 2017 -0500
# Node ID a58ab92c962337fe177001ec17df0efc673e8279
# Parent  fd22223e0c7b22d8807e30f96f734d10c59f4433
_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.

diff --git a/hglib/client.py b/hglib/client.py
--- a/hglib/client.py
+++ b/hglib/client.py
@@ -147,7 +147,10 @@ class hgclient(object):
     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 @@ class hgclient(object):
             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()))


More information about the Mercurial-devel mailing list