changeset 34105:c037fd655b47

ssh: fix flakey ssh errors on BSD systems There's been a persistent issue with flakiness on BSD systems (like OSX) where the 'no suitable response from remote hg' message would sometimes not appear. This was caused by one of the earlier calls failing with a "IOError: Broken pipe". Catching those errors and printing the same message removes the flakiness. Differential Revision: https://phab.mercurial-scm.org/D687
author Durham Goode <durham@fb.com>
date Mon, 11 Sep 2017 15:59:18 -0700
parents f698bb31bdfb
children 06eb3de47649
files mercurial/sshpeer.py
diffstat 1 files changed, 23 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/sshpeer.py	Mon Sep 11 13:03:27 2017 -0700
+++ b/mercurial/sshpeer.py	Mon Sep 11 15:59:18 2017 -0700
@@ -203,23 +203,33 @@
         self._pipei = doublepipe(self.ui, self._pipei, self._pipee)
         self._pipeo = doublepipe(self.ui, self._pipeo, self._pipee)
 
-        # skip any noise generated by remote shell
-        self._callstream("hello")
-        r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40)))
+        def badresponse():
+            self._abort(error.RepoError(_('no suitable response from '
+                                          'remote hg')))
+
+        try:
+            # skip any noise generated by remote shell
+            self._callstream("hello")
+            r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40)))
+        except IOError:
+            badresponse()
+
         lines = ["", "dummy"]
         max_noise = 500
         while lines[-1] and max_noise:
-            l = r.readline()
-            self._readerr()
-            if lines[-1] == "1\n" and l == "\n":
-                break
-            if l:
-                self.ui.debug("remote: ", l)
-            lines.append(l)
-            max_noise -= 1
+            try:
+                l = r.readline()
+                self._readerr()
+                if lines[-1] == "1\n" and l == "\n":
+                    break
+                if l:
+                    self.ui.debug("remote: ", l)
+                lines.append(l)
+                max_noise -= 1
+            except IOError:
+                badresponse()
         else:
-            self._abort(error.RepoError(_('no suitable response from '
-                                          'remote hg')))
+            badresponse()
 
         self._caps = set()
         for l in reversed(lines):