This revision was automatically updated to reflect the committed changes.
Closed by commit rHG11ba1a96f946: sshpeer: defer pipe buffering and stderr 
sidechannel binding (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2383?vs=5969&id=6001

REVISION DETAIL
  https://phab.mercurial-scm.org/D2383

AFFECTED FILES
  mercurial/sshpeer.py
  tests/test-check-interfaces.py

CHANGE DETAILS

diff --git a/tests/test-check-interfaces.py b/tests/test-check-interfaces.py
--- a/tests/test-check-interfaces.py
+++ b/tests/test-check-interfaces.py
@@ -59,16 +59,20 @@
     def badmethod(self):
         pass
 
+class dummypipe(object):
+    def close(self):
+        pass
+
 def main():
     ui = uimod.ui()
 
     checkobject(badpeer())
     checkobject(httppeer.httppeer(ui, 'http://localhost'))
     checkobject(localrepo.localpeer(dummyrepo()))
-    checkobject(sshpeer.sshv1peer(ui, 'ssh://localhost/foo', None, None, None,
-                                  None, None))
-    checkobject(sshpeer.sshv2peer(ui, 'ssh://localhost/foo', None, None, None,
-                                  None, None))
+    checkobject(sshpeer.sshv1peer(ui, 'ssh://localhost/foo', None, dummypipe(),
+                                  dummypipe(), None, None))
+    checkobject(sshpeer.sshv2peer(ui, 'ssh://localhost/foo', None, dummypipe(),
+                                  dummypipe(), None, None))
     checkobject(bundlerepo.bundlepeer(dummyrepo()))
     checkobject(statichttprepo.statichttppeer(dummyrepo()))
     checkobject(unionrepo.unionpeer(dummyrepo()))
diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -156,13 +156,13 @@
     # move to threading.
     stdin, stdout, stderr, proc = util.popen4(cmd, bufsize=0, env=sshenv)
 
-    stdout = doublepipe(ui, util.bufferedinputpipe(stdout), stderr)
-    stdin = doublepipe(ui, stdin, stderr)
-
     return proc, stdin, stdout, stderr
 
 def _performhandshake(ui, stdin, stdout, stderr):
     def badresponse():
+        # Flush any output on stderr.
+        _forwardoutput(ui, stderr)
+
         msg = _('no suitable response from remote hg')
         hint = ui.config('ui', 'ssherrorhint')
         raise error.RepoError(msg, hint=hint)
@@ -331,6 +331,9 @@
     if not caps:
         badresponse()
 
+    # Flush any output on stderr before proceeding.
+    _forwardoutput(ui, stderr)
+
     return protoname, caps
 
 class sshv1peer(wireproto.wirepeer):
@@ -347,6 +350,12 @@
         # self._subprocess is unused. Keeping a handle on the process
         # holds a reference and prevents it from being garbage collected.
         self._subprocess = proc
+
+        # And we hook up our "doublepipe" wrapper to allow querying
+        # stderr any time we perform I/O.
+        stdout = doublepipe(ui, util.bufferedinputpipe(stdout), stderr)
+        stdin = doublepipe(ui, stdin, stderr)
+
         self._pipeo = stdin
         self._pipei = stdout
         self._pipee = stderr



To: indygreg, #hg-reviewers, yuja
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to