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) |
|