[PATCH 3 of 5] sshpeer: extract the forward output logic
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Wed May 20 23:53:22 UTC 2015
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1432009151 18000
# Mon May 18 23:19:11 2015 -0500
# Node ID 687fd403550ff2fd9eec1fbc00c3978ae3d95da8
# Parent 2e5f389856a5d976cd853ab94fd125955413d2f0
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.
diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -25,10 +25,19 @@ def _serverquote(s):
'''quote a string for the remote shell ... which we assume is sh'''
if re.match('[a-zA-Z0-9@%_+=:,./-]*$', s):
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
self.ui = ui
self.pipeo = self.pipei = self.pipee = None
@@ -106,14 +115,11 @@ class sshpeer(wireproto.wirepeer):
def _capabilities(self):
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()
raise exception
More information about the Mercurial-devel
mailing list