Patchwork D2032: sshpeer: clean up API for sshpeer.__init__ (API)

login
register
mail settings
Submitter phabricator
Date Feb. 5, 2018, 10:21 p.m.
Message ID <3dede4de0ce49395e86e9e6a09c1b794@localhost.localdomain>
Download mbox | patch
Permalink /patch/27338/
State Not Applicable
Headers show

Comments

phabricator - Feb. 5, 2018, 10:21 p.m.
indygreg updated this revision to Diff 5233.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2032?vs=5190&id=5233

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

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

CHANGE DETAILS




To: indygreg, #hg-reviewers, lothiraldan
Cc: mercurial-devel

Patch

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
@@ -69,8 +69,8 @@ 
     checkobject(badpeer())
     checkobject(httppeer.httppeer(ui, 'http://localhost'))
     checkobject(localrepo.localpeer(dummyrepo()))
-    checkobject(testingsshpeer(ui, 'ssh://localhost/foo', False,
-                               (None, None, None, None)))
+    checkobject(testingsshpeer(ui, 'ssh://localhost/foo', None, None, 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
@@ -157,12 +157,21 @@ 
     return proc, stdin, stdout, stderr
 
 class sshpeer(wireproto.wirepeer):
-    def __init__(self, ui, path, create=False, sshstate=None):
-        self._url = path
+    def __init__(self, ui, url, proc, stdin, stdout, stderr):
+        """Create a peer from an existing SSH connection.
+
+        ``proc`` is a handle on the underlying SSH process.
+        ``stdin``, ``stdout``, and ``stderr`` are handles on the stdio
+        pipes for that process.
+        """
+        self._url = url
         self._ui = ui
         # self._subprocess is unused. Keeping a handle on the process
         # holds a reference and prevents it from being garbage collected.
-        self._subprocess, self._pipei, self._pipeo, self._pipee = sshstate
+        self._subprocess = proc
+        self._pipeo = stdin
+        self._pipei = stdout
+        self._pipee = stderr
 
         self._validaterepo()
 
@@ -386,6 +395,4 @@ 
     proc, stdin, stdout, stderr = _makeconnection(ui, sshcmd, args, remotecmd,
                                                   remotepath, sshenv)
 
-    sshstate = (proc, stdout, stdin, stderr)
-
-    return sshpeer(ui, path, create=create, sshstate=sshstate)
+    return sshpeer(ui, path, proc, stdin, stdout, stderr)