changeset 25244:cf90764f40a4

sshpeer: extract the forward output logic We are about to make a more aggressive use of this when reading and writing on the other pipes. We it needs to be reusable.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 18 May 2015 23:19:11 -0500
parents d65243d28749
children 504ef9c49f4a
files mercurial/sshpeer.py
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/sshpeer.py	Wed May 20 12:33:12 2015 -0500
+++ b/mercurial/sshpeer.py	Mon May 18 23:19:11 2015 -0500
@@ -27,6 +27,15 @@
         return s
     return "'%s'" % s.replace("'", "'\\''")
 
+def _forwardoutput(ui, pipe):
+    """display all data currently available on pipe as remote output.
+
+    This is non blocking."""
+    s = util.readpipe(pipe)
+    if s:
+        for l in s.splitlines():
+            ui.status(_("remote: "), l, '\n')
+
 class sshpeer(wireproto.wirepeer):
     def __init__(self, ui, path, create=False):
         self._url = path
@@ -108,10 +117,7 @@
         return self._caps
 
     def readerr(self):
-        s = util.readpipe(self.pipee)
-        if s:
-            for l in s.splitlines():
-                self.ui.status(_("remote: "), l, '\n')
+        _forwardoutput(self.ui, self.pipee)
 
     def _abort(self, exception):
         self.cleanup()