Changeset View
Changeset View
Standalone View
Standalone View
mercurial/sshpeer.py
Show All 18 Lines | from . import ( | ||||
wireprotoserver, | wireprotoserver, | ||||
wireprototypes, | wireprototypes, | ||||
wireprotov1peer, | wireprotov1peer, | ||||
wireprotov1server, | wireprotov1server, | ||||
) | ) | ||||
from .utils import ( | from .utils import ( | ||||
procutil, | procutil, | ||||
stringutil, | stringutil, | ||||
urlutil, | |||||
) | ) | ||||
def _serverquote(s): | def _serverquote(s): | ||||
"""quote a string for the remote shell ... which we assume is sh""" | """quote a string for the remote shell ... which we assume is sh""" | ||||
if not s: | if not s: | ||||
return s | return s | ||||
if re.match(b'[a-zA-Z0-9@%_+=:,./-]*$', s): | if re.match(b'[a-zA-Z0-9@%_+=:,./-]*$', s): | ||||
▲ Show 20 Lines • Show All 622 Lines • ▼ Show 20 Line(s) | else: | ||||
) | ) | ||||
def instance(ui, path, create, intents=None, createopts=None): | def instance(ui, path, create, intents=None, createopts=None): | ||||
"""Create an SSH peer. | """Create an SSH peer. | ||||
The returned object conforms to the ``wireprotov1peer.wirepeer`` interface. | The returned object conforms to the ``wireprotov1peer.wirepeer`` interface. | ||||
""" | """ | ||||
u = util.url(path, parsequery=False, parsefragment=False) | u = urlutil.url(path, parsequery=False, parsefragment=False) | ||||
if u.scheme != b'ssh' or not u.host or u.path is None: | if u.scheme != b'ssh' or not u.host or u.path is None: | ||||
raise error.RepoError(_(b"couldn't parse location %s") % path) | raise error.RepoError(_(b"couldn't parse location %s") % path) | ||||
util.checksafessh(path) | urlutil.checksafessh(path) | ||||
if u.passwd is not None: | if u.passwd is not None: | ||||
raise error.RepoError(_(b'password in URL not supported')) | raise error.RepoError(_(b'password in URL not supported')) | ||||
sshcmd = ui.config(b'ui', b'ssh') | sshcmd = ui.config(b'ui', b'ssh') | ||||
remotecmd = ui.config(b'ui', b'remotecmd') | remotecmd = ui.config(b'ui', b'remotecmd') | ||||
sshaddenv = dict(ui.configitems(b'sshenv')) | sshaddenv = dict(ui.configitems(b'sshenv')) | ||||
sshenv = procutil.shellenviron(sshaddenv) | sshenv = procutil.shellenviron(sshaddenv) | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |