mercurial/sshpeer.py
changeset 49761 73ed1d13c0bf
parent 49757 5f71fff8dc74
child 50388 ed052780ad5e
equal deleted inserted replaced
49760:5bceea1a8234 49761:73ed1d13c0bf
   370     return protoname, caps
   370     return protoname, caps
   371 
   371 
   372 
   372 
   373 class sshv1peer(wireprotov1peer.wirepeer):
   373 class sshv1peer(wireprotov1peer.wirepeer):
   374     def __init__(
   374     def __init__(
   375         self, ui, url, proc, stdin, stdout, stderr, caps, autoreadstderr=True
   375         self, ui, path, proc, stdin, stdout, stderr, caps, autoreadstderr=True
   376     ):
   376     ):
   377         """Create a peer from an existing SSH connection.
   377         """Create a peer from an existing SSH connection.
   378 
   378 
   379         ``proc`` is a handle on the underlying SSH process.
   379         ``proc`` is a handle on the underlying SSH process.
   380         ``stdin``, ``stdout``, and ``stderr`` are handles on the stdio
   380         ``stdin``, ``stdout``, and ``stderr`` are handles on the stdio
   381         pipes for that process.
   381         pipes for that process.
   382         ``caps`` is a set of capabilities supported by the remote.
   382         ``caps`` is a set of capabilities supported by the remote.
   383         ``autoreadstderr`` denotes whether to automatically read from
   383         ``autoreadstderr`` denotes whether to automatically read from
   384         stderr and to forward its output.
   384         stderr and to forward its output.
   385         """
   385         """
   386         super().__init__(ui)
   386         super().__init__(ui, path=path)
   387         self._url = url
       
   388         # self._subprocess is unused. Keeping a handle on the process
   387         # self._subprocess is unused. Keeping a handle on the process
   389         # holds a reference and prevents it from being garbage collected.
   388         # holds a reference and prevents it from being garbage collected.
   390         self._subprocess = proc
   389         self._subprocess = proc
   391 
   390 
   392         # And we hook up our "doublepipe" wrapper to allow querying
   391         # And we hook up our "doublepipe" wrapper to allow querying
   409     }
   408     }
   410 
   409 
   411     # Begin of ipeerconnection interface.
   410     # Begin of ipeerconnection interface.
   412 
   411 
   413     def url(self):
   412     def url(self):
   414         return self._url
   413         return self.path.loc
   415 
   414 
   416     def local(self):
   415     def local(self):
   417         return None
   416         return None
   418 
   417 
   419     def canpush(self):
   418     def canpush(self):
   610 def make_peer(ui, path, create, intents=None, createopts=None):
   609 def make_peer(ui, path, create, intents=None, createopts=None):
   611     """Create an SSH peer.
   610     """Create an SSH peer.
   612 
   611 
   613     The returned object conforms to the ``wireprotov1peer.wirepeer`` interface.
   612     The returned object conforms to the ``wireprotov1peer.wirepeer`` interface.
   614     """
   613     """
   615     path = path.loc
   614     u = urlutil.url(path.loc, parsequery=False, parsefragment=False)
   616     u = urlutil.url(path, parsequery=False, parsefragment=False)
       
   617     if u.scheme != b'ssh' or not u.host or u.path is None:
   615     if u.scheme != b'ssh' or not u.host or u.path is None:
   618         raise error.RepoError(_(b"couldn't parse location %s") % path)
   616         raise error.RepoError(_(b"couldn't parse location %s") % path)
   619 
   617 
   620     urlutil.checksafessh(path)
   618     urlutil.checksafessh(path.loc)
   621 
   619 
   622     if u.passwd is not None:
   620     if u.passwd is not None:
   623         raise error.RepoError(_(b'password in URL not supported'))
   621         raise error.RepoError(_(b'password in URL not supported'))
   624 
   622 
   625     sshcmd = ui.config(b'ui', b'ssh')
   623     sshcmd = ui.config(b'ui', b'ssh')