Mercurial > hg
comparison mercurial/sshpeer.py @ 34145:1908dc958639 stable
ssh: fix flakey ssh errors on BSD systems
This is a trivial backport of c037fd655b47 performed by
augie@google.com, but the change is still really Durham's not mine, so
I [augie] am leaving him as the author.
author | Durham Goode <durham@fb.com> |
---|---|
date | Mon, 11 Sep 2017 15:59:18 -0700 |
parents | 8cb9e921ef8c |
children | 2844c4bd5a39 |
comparison
equal
deleted
inserted
replaced
34144:91f0677dc920 | 34145:1908dc958639 |
---|---|
188 | 188 |
189 self.pipei = util.bufferedinputpipe(self.pipei) | 189 self.pipei = util.bufferedinputpipe(self.pipei) |
190 self.pipei = doublepipe(self.ui, self.pipei, self.pipee) | 190 self.pipei = doublepipe(self.ui, self.pipei, self.pipee) |
191 self.pipeo = doublepipe(self.ui, self.pipeo, self.pipee) | 191 self.pipeo = doublepipe(self.ui, self.pipeo, self.pipee) |
192 | 192 |
193 # skip any noise generated by remote shell | 193 def badresponse(): |
194 self._callstream("hello") | 194 self._abort(error.RepoError(_('no suitable response from ' |
195 r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40))) | 195 'remote hg'))) |
196 | |
197 try: | |
198 # skip any noise generated by remote shell | |
199 self._callstream("hello") | |
200 r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40))) | |
201 except IOError: | |
202 badresponse() | |
203 | |
196 lines = ["", "dummy"] | 204 lines = ["", "dummy"] |
197 max_noise = 500 | 205 max_noise = 500 |
198 while lines[-1] and max_noise: | 206 while lines[-1] and max_noise: |
199 l = r.readline() | 207 try: |
200 self.readerr() | 208 l = r.readline() |
201 if lines[-1] == "1\n" and l == "\n": | 209 self.readerr() |
202 break | 210 if lines[-1] == "1\n" and l == "\n": |
203 if l: | 211 break |
204 self.ui.debug("remote: ", l) | 212 if l: |
205 lines.append(l) | 213 self.ui.debug("remote: ", l) |
206 max_noise -= 1 | 214 lines.append(l) |
215 max_noise -= 1 | |
216 except IOError: | |
217 badresponse() | |
207 else: | 218 else: |
208 self._abort(error.RepoError(_('no suitable response from ' | 219 badresponse() |
209 'remote hg'))) | |
210 | 220 |
211 self._caps = set() | 221 self._caps = set() |
212 for l in reversed(lines): | 222 for l in reversed(lines): |
213 if l.startswith("capabilities:"): | 223 if l.startswith("capabilities:"): |
214 self._caps.update(l[:-1].split(":")[1].split()) | 224 self._caps.update(l[:-1].split(":")[1].split()) |