sshpeer: add implementation of _calltwowaystream
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 15 Apr 2014 17:18:35 -0400
changeset 21073 83ce71ef7804
parent 21072 0879352d67d8
child 21074 f8a0d82b0463
sshpeer: add implementation of _calltwowaystream This implements the call needed by bundle2. The error handling is a bit flaky right now, but bundle2 error handling in general is still flaky anyway. Bundle2 is still disabled by default, I do not expect this to be a problem.
mercurial/sshpeer.py
--- a/mercurial/sshpeer.py	Tue Apr 15 17:19:46 2014 -0400
+++ b/mercurial/sshpeer.py	Tue Apr 15 17:18:35 2014 -0400
@@ -179,6 +179,18 @@
             return '', r
         return self._recv(), ''
 
+    def _calltwowaystream(self, cmd, fp, **args):
+        r = self._call(cmd, **args)
+        if r:
+            # XXX needs to be made better
+            raise util.Abort('unexpected remote reply: %s' % r)
+        while True:
+            d = fp.read(4096)
+            if not d:
+                break
+            self._send(d)
+        self._send("", flush=True)
+        return self.pipei
 
     def _recv(self):
         l = self.pipei.readline()