2010-12-26 01:49:16 +03:00
|
|
|
from mercurial import util
|
|
|
|
|
2010-12-23 01:57:26 +03:00
|
|
|
class SSHVendor(object):
|
|
|
|
"""Parent class for ui-linked Vendor classes."""
|
|
|
|
|
|
|
|
|
|
|
|
def generate_ssh_vendor(ui):
|
|
|
|
"""
|
|
|
|
Allows dulwich to use hg's ui.ssh config. The dulwich.client.get_ssh_vendor
|
|
|
|
property should point to the return value.
|
|
|
|
"""
|
|
|
|
|
|
|
|
class _Vendor(SSHVendor):
|
2013-09-13 04:42:27 +04:00
|
|
|
def run_command(self, host, command, username=None, port=None):
|
2010-12-23 01:57:26 +03:00
|
|
|
from dulwich.client import SubprocessWrapper
|
|
|
|
from mercurial import util
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
sshcmd = ui.config("ui", "ssh", "ssh")
|
|
|
|
args = util.sshargs(sshcmd, host, username, port)
|
2010-12-26 01:49:16 +03:00
|
|
|
cmd = '%s %s %s' % (sshcmd, args,
|
|
|
|
util.shellquote(' '.join(command)))
|
|
|
|
ui.debug('calling ssh: %s\n' % cmd)
|
|
|
|
print command
|
|
|
|
proc = subprocess.Popen(util.quotecommand(cmd), shell=True,
|
2010-12-23 01:57:26 +03:00
|
|
|
stdin=subprocess.PIPE,
|
|
|
|
stdout=subprocess.PIPE)
|
|
|
|
return SubprocessWrapper(proc)
|
|
|
|
|
|
|
|
return _Vendor
|