annotate hggit/_ssh.py @ 747:c1b39434ff56

_ssh: fix trailing whitespace
author Augie Fackler <raf@durin42.com>
date Sat, 23 Aug 2014 12:00:48 -0400
parents 980c37f6a8f9
children 8b85933fb095
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
371
240573913439 Create ssh subprocess with a shell command instead of an exec list
Mads Kiilerich <mads@kiilerich.com>
parents: 369
diff changeset
1 from mercurial import util
240573913439 Create ssh subprocess with a shell command instead of an exec list
Mads Kiilerich <mads@kiilerich.com>
parents: 369
diff changeset
2
369
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
3 class SSHVendor(object):
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
4 """Parent class for ui-linked Vendor classes."""
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
5
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
6
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
7 def generate_ssh_vendor(ui):
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
8 """
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
9 Allows dulwich to use hg's ui.ssh config. The dulwich.client.get_ssh_vendor
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
10 property should point to the return value.
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
11 """
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
12
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
13 class _Vendor(SSHVendor):
606
980c37f6a8f9 Upgraded to use latest version of dulwich (0.9.1).
Alex Regueiro <alex@noldorin.com>
parents: 371
diff changeset
14 def run_command(self, host, command, username=None, port=None):
369
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
15 from dulwich.client import SubprocessWrapper
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
16 from mercurial import util
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
17 import subprocess
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
18
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
19 sshcmd = ui.config("ui", "ssh", "ssh")
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
20 args = util.sshargs(sshcmd, host, username, port)
747
c1b39434ff56 _ssh: fix trailing whitespace
Augie Fackler <raf@durin42.com>
parents: 606
diff changeset
21 cmd = '%s %s %s' % (sshcmd, args,
371
240573913439 Create ssh subprocess with a shell command instead of an exec list
Mads Kiilerich <mads@kiilerich.com>
parents: 369
diff changeset
22 util.shellquote(' '.join(command)))
240573913439 Create ssh subprocess with a shell command instead of an exec list
Mads Kiilerich <mads@kiilerich.com>
parents: 369
diff changeset
23 ui.debug('calling ssh: %s\n' % cmd)
240573913439 Create ssh subprocess with a shell command instead of an exec list
Mads Kiilerich <mads@kiilerich.com>
parents: 369
diff changeset
24 print command
240573913439 Create ssh subprocess with a shell command instead of an exec list
Mads Kiilerich <mads@kiilerich.com>
parents: 369
diff changeset
25 proc = subprocess.Popen(util.quotecommand(cmd), shell=True,
369
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
26 stdin=subprocess.PIPE,
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
27 stdout=subprocess.PIPE)
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
28 return SubprocessWrapper(proc)
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
29
e5c743cd0da1 pass hg's ui.ssh config to dulwich
Tay Ray Chuan <rctay89@gmail.com>
parents:
diff changeset
30 return _Vendor