Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/hg.py @ 817:cf1d9a01dd92
Make ssh URL parsing more robust
author | mpm@selenic.com |
---|---|
date | Mon, 01 Aug 2005 23:23:51 -0800 |
parents | 8674b7803714 |
children | 0932bc2fb2be 1fe3b14c7044 |
comparison
equal
deleted
inserted
replaced
816:8674b7803714 | 817:cf1d9a01dd92 |
---|---|
1877 class sshrepository: | 1877 class sshrepository: |
1878 def __init__(self, ui, path): | 1878 def __init__(self, ui, path): |
1879 self.url = path | 1879 self.url = path |
1880 self.ui = ui | 1880 self.ui = ui |
1881 | 1881 |
1882 m = re.match(r'ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?', path) | 1882 m = re.match(r'ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))', path) |
1883 if not m: | 1883 if not m: |
1884 raise RepoError("couldn't parse destination %s\n" % path) | 1884 raise RepoError("couldn't parse destination %s" % path) |
1885 | 1885 |
1886 self.user = m.group(2) | 1886 self.user = m.group(2) |
1887 self.host = m.group(3) | 1887 self.host = m.group(3) |
1888 self.port = m.group(5) | 1888 self.port = m.group(5) |
1889 self.path = m.group(7) | 1889 self.path = m.group(7) |
1890 | 1890 |
1891 args = self.user and ("%s@%s" % (self.user, self.host)) or self.host | 1891 args = self.user and ("%s@%s" % (self.user, self.host)) or self.host |
1892 args = self.port and ("%s -p %s") % (args, self.port) or args | 1892 args = self.port and ("%s -p %s") % (args, self.port) or args |
1893 path = self.path or "" | 1893 path = self.path or "" |
1894 | |
1895 if not path: | |
1896 raise RepoError("no remote repository path specified") | |
1894 | 1897 |
1895 cmd = "ssh %s 'hg -R %s serve --stdio'" | 1898 cmd = "ssh %s 'hg -R %s serve --stdio'" |
1896 cmd = cmd % (args, path) | 1899 cmd = cmd % (args, path) |
1897 | 1900 |
1898 self.pipeo, self.pipei, self.pipee = os.popen3(cmd) | 1901 self.pipeo, self.pipei, self.pipee = os.popen3(cmd) |
1904 l = self.pipee.readline() | 1907 l = self.pipee.readline() |
1905 if not l: break | 1908 if not l: break |
1906 self.ui.status("remote: ", l) | 1909 self.ui.status("remote: ", l) |
1907 | 1910 |
1908 def __del__(self): | 1911 def __del__(self): |
1909 self.pipeo.close() | 1912 try: |
1910 self.pipei.close() | 1913 self.pipeo.close() |
1911 for l in self.pipee: | 1914 self.pipei.close() |
1912 self.ui.status("remote: ", l) | 1915 for l in self.pipee: |
1913 self.pipee.close() | 1916 self.ui.status("remote: ", l) |
1917 self.pipee.close() | |
1918 except: | |
1919 pass | |
1914 | 1920 |
1915 def dev(self): | 1921 def dev(self): |
1916 return -1 | 1922 return -1 |
1917 | 1923 |
1918 def do_cmd(self, cmd, **args): | 1924 def do_cmd(self, cmd, **args): |