[PATCH] Teach Mercurial to handle URLs of the form *sh://host/path, such as
peter.kourzanov at xs4all.nl
peter.kourzanov at xs4all.nl
Tue May 20 10:23:32 CDT 2008
# HG changeset patch
# User Pjotr Kourzanov <peter.kourzanov at xs4all.nl>
# Date 1211296862 -7200
# Node ID e47daffa9b1c21d44d72f96b834df52ebe721f7c
# Parent 22c635868d6bba769d3ad29a29e084cda75dc9a0
Teach Mercurial to handle URLs of the form *sh://host/path, such as
ssh://host or krb5-rsh://host.
This can be used to directly specify in the URL which remote shell
client to use, such as ssh, rsh, krb5-rsh etc.
If the ui.ssh option is specified, it still takes precedence over
this, allowing for standard behaviour for ssh://host URLs
diff -r 22c635868d6b -r e47daffa9b1c mercurial/hg.py
--- a/mercurial/hg.py Tue May 20 17:17:15 2008 +0200
+++ b/mercurial/hg.py Tue May 20 17:21:02 2008 +0200
@@ -8,7 +8,7 @@
from i18n import _
import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo
-import errno, lock, os, shutil, util, extensions
+import errno, lock, os, shutil, util, extensions, re
import merge as _merge
import verify as _verify
@@ -40,7 +40,12 @@
c = path.find(':')
if c > 0:
scheme = path[:c]
- thing = schemes.get(scheme) or schemes['file']
+ thing = schemes.get(scheme)
+ if not thing:
+ if re.match(r'^[^:/]+sh',scheme):
+ thing=sshrepo
+ else:
+ thing=schemes['file']
try:
return thing(path)
except TypeError:
diff -r 22c635868d6b -r e47daffa9b1c mercurial/sshrepo.py
--- a/mercurial/sshrepo.py Tue May 20 17:17:15 2008 +0200
+++ b/mercurial/sshrepo.py Tue May 20 17:21:02 2008 +0200
@@ -24,16 +24,19 @@
self._url = path
self.ui = ui
- m = re.match(r'^ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?$', path)
+ m = re.match(r'^([^:/]+sh)://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?$', path)
if not m:
self.raise_(repo.RepoError(_("couldn't parse location %s") % path))
- self.user = m.group(2)
- self.host = m.group(3)
- self.port = m.group(5)
- self.path = m.group(7) or "."
+ self.user = m.group(3)
+ self.host = m.group(4)
+ self.port = m.group(6)
+ self.path = m.group(8) or "."
- sshcmd = self.ui.config("ui", "ssh", "ssh")
+ sshcmd = self.ui.config("ui", "ssh", "ssh")
+ if not sshcmd:
+ sshcmd = m.group(1)
+
remotecmd = self.ui.config("ui", "remotecmd", "hg")
args = util.sshargs(sshcmd, self.host, self.user, self.port)
More information about the Mercurial-devel
mailing list