[PATCH] "Classic" SSH scheme

Sébastien Pierre sebastien at xprima.com
Tue Jul 11 18:05:35 UTC 2006


Hi all,

Regarding our discussion on the usability problems with the current SSH
scheme, here is a small patch that makes it more natural.

To test the patch, you can try with cloning an existing repo on a
server on which you have an SSH account.

 -- Sébastien

# HG changeset patch
# User Sébastien Pierre <sebastien at xprima.com>
# Date 1152640843 14400
# Node ID 6f87f9e3af2397e82e6ddcaed4d0e698452a9bf3
# Parent  8210cf2ec19debd36007f06de15cd90af906f9a6
Changed SSH URL syntax to a more 'standard' syntax.
Preceding syntax was like
  ssh://[user@]host[:port][/path]
and it is now like
  ssh://[user@]host[:port][:path]
which is more similary to the way SSH works. The path is now relative by
default, and can be made absolute by using a slash. Using the ~ for home is also
supported. Commands documentation was also updated in consequence.

diff -r 8210cf2ec19d -r 6f87f9e3af23 mercurial/commands.py
--- a/mercurial/commands.py	Mon Jul 10 09:36:56 2006 -0700
+++ b/mercurial/commands.py	Tue Jul 11 14:00:43 2006 -0400
@@ -2230,13 +2230,11 @@ def pull(ui, repo, source="default", **o
       local/filesystem/path
       http://[user@]host[:port][/path]
       https://[user@]host[:port][/path]
-      ssh://[user@]host[:port][/path]
+      ssh://[user@]host[:port][:path]
 
     Some notes about using SSH with Mercurial:
     - SSH requires an accessible shell account on the destination machine
       and a copy of hg in the remote path or specified with as remotecmd.
-    - /path is relative to the remote user's home directory by default.
-      Use two slashes at the start of a path to specify an absolute path.
     - Mercurial doesn't use its own compression via SSH; the right thing
       to do is to configure it in your ~/.ssh/ssh_config, e.g.:
         Host *.mylocalnetwork.example.com
@@ -2280,7 +2278,7 @@ def push(ui, repo, dest=None, **opts):
     Valid URLs are of the form:
 
       local/filesystem/path
-      ssh://[user@]host[:port][/path]
+      ssh://[user@]host[:port][:path]
 
     Look at the help text for the pull command for important details
     about ssh:// URLs.
diff -r 8210cf2ec19d -r 6f87f9e3af23 mercurial/sshrepo.py
--- a/mercurial/sshrepo.py	Mon Jul 10 09:36:56 2006 -0700
+++ b/mercurial/sshrepo.py	Tue Jul 11 14:00:43 2006 -0400
@@ -15,15 +15,12 @@ class sshrepository(remoterepository):
     def __init__(self, ui, path, create=0):
         self.url = path
         self.ui = ui
-
-        m = re.match(r'ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?', path)
+        #              SSH://[USER___@]HOST____[:PORT][:PATH]
+        m = re.match(r'ssh://(([^@]+)@)?([^:]+)(:(\d+))?(:(.*))?', path)
         if not m:
             raise hg.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, self.host, _, self.port, _, self.path = m.groups()
+        if not self.path: self.path = "."
 
         args = self.user and ("%s@%s" % (self.user, self.host)) or self.host
         args = self.port and ("%s -p %s") % (args, self.port) or args




More information about the Mercurial mailing list