Mercurial > public > mercurial-scm > hg
comparison mercurial/sshpeer.py @ 35936:f8f034344b39
sshpeer: clean up API for sshpeer.__init__ (API)
Our refactoring left the state of sshpeer.__init__ in a poor
state. "create" was no longer used. Process/pipe arguments were
passed poorly. "name" was really a URL.
This commit cleans all that up.
.. api::
sshpeer.sshpeer.__init__ now receives arguments describing an
existing connection instead of creating a connection itself.
Differential Revision: https://phab.mercurial-scm.org/D2032
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 05 Feb 2018 14:17:24 -0800 |
parents | 00b9e26d727b |
children | a9cffd14aa04 |
comparison
equal
deleted
inserted
replaced
35935:00b9e26d727b | 35936:f8f034344b39 |
---|---|
155 stdin = doublepipe(ui, stdin, stderr) | 155 stdin = doublepipe(ui, stdin, stderr) |
156 | 156 |
157 return proc, stdin, stdout, stderr | 157 return proc, stdin, stdout, stderr |
158 | 158 |
159 class sshpeer(wireproto.wirepeer): | 159 class sshpeer(wireproto.wirepeer): |
160 def __init__(self, ui, path, create=False, sshstate=None): | 160 def __init__(self, ui, url, proc, stdin, stdout, stderr): |
161 self._url = path | 161 """Create a peer from an existing SSH connection. |
162 | |
163 ``proc`` is a handle on the underlying SSH process. | |
164 ``stdin``, ``stdout``, and ``stderr`` are handles on the stdio | |
165 pipes for that process. | |
166 """ | |
167 self._url = url | |
162 self._ui = ui | 168 self._ui = ui |
163 # self._subprocess is unused. Keeping a handle on the process | 169 # self._subprocess is unused. Keeping a handle on the process |
164 # holds a reference and prevents it from being garbage collected. | 170 # holds a reference and prevents it from being garbage collected. |
165 self._subprocess, self._pipei, self._pipeo, self._pipee = sshstate | 171 self._subprocess = proc |
172 self._pipeo = stdin | |
173 self._pipei = stdout | |
174 self._pipee = stderr | |
166 | 175 |
167 self._validaterepo() | 176 self._validaterepo() |
168 | 177 |
169 # Begin of _basepeer interface. | 178 # Begin of _basepeer interface. |
170 | 179 |
384 raise error.RepoError(_('could not create remote repo')) | 393 raise error.RepoError(_('could not create remote repo')) |
385 | 394 |
386 proc, stdin, stdout, stderr = _makeconnection(ui, sshcmd, args, remotecmd, | 395 proc, stdin, stdout, stderr = _makeconnection(ui, sshcmd, args, remotecmd, |
387 remotepath, sshenv) | 396 remotepath, sshenv) |
388 | 397 |
389 sshstate = (proc, stdout, stdin, stderr) | 398 return sshpeer(ui, path, proc, stdin, stdout, stderr) |
390 | |
391 return sshpeer(ui, path, create=create, sshstate=sshstate) |