Mercurial > hg > hg-git
changeset 369:e5c743cd0da1
pass hg's ui.ssh config to dulwich
This allows Windows users to override dulwich's default (the unix-y
ssh).
author | Tay Ray Chuan <rctay89@gmail.com> |
---|---|
date | Wed, 22 Dec 2010 16:57:26 -0600 |
parents | ae78f94f64fd |
children | 37a06b903df6 |
files | hggit/_ssh.py hggit/git_handler.py |
diffstat | 2 files changed, 30 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/hggit/_ssh.py @@ -0,0 +1,25 @@ +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): + def connect_ssh(self, host, command, username=None, port=None): + from dulwich.client import SubprocessWrapper + from mercurial import util + import subprocess + + sshcmd = ui.config("ui", "ssh", "ssh") + args = util.sshargs(sshcmd, host, username, port) + + proc = subprocess.Popen([sshcmd, args] + command, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE) + return SubprocessWrapper(proc) + + return _Vendor
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -13,6 +13,7 @@ from mercurial import context, util as hgutil from mercurial import error +import _ssh import util class GitHandler(object): @@ -68,7 +69,6 @@ file.write("%s %s\n" % (gitsha, hgsha)) file.rename() - def load_tags(self): self.tags = {} if os.path.exists(self.repo.join(self.tagsfile)): @@ -890,6 +890,10 @@ return string.decode('ascii', 'replace').encode('utf-8') def get_transport_and_path(self, uri): + # pass hg's ui.ssh config to dulwich + if not issubclass(client.get_ssh_vendor, _ssh.SSHVendor): + client.get_ssh_vendor = _ssh.generate_ssh_vendor(self.ui) + for handler, transport in (("git://", client.TCPGitClient), ("git@", client.SSHGitClient), ("git+ssh://", client.SSHGitClient)):