Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/url.py @ 13807:974490c1768f
url: deal with drive letters
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 30 Mar 2011 13:34:39 -0500 |
parents | 463aca32a937 |
children | 03dfe0c85c1a |
comparison
equal
deleted
inserted
replaced
13806:8ba08a16e4e0 | 13807:974490c1768f |
---|---|
37 <url scheme: 'ssh', host: '[::1]', port: '2200', path: '/home/joe/repo'> | 37 <url scheme: 'ssh', host: '[::1]', port: '2200', path: '/home/joe/repo'> |
38 >>> url('file:///home/joe/repo') | 38 >>> url('file:///home/joe/repo') |
39 <url scheme: 'file', path: '/home/joe/repo'> | 39 <url scheme: 'file', path: '/home/joe/repo'> |
40 >>> url('bundle:foo') | 40 >>> url('bundle:foo') |
41 <url scheme: 'bundle', path: 'foo'> | 41 <url scheme: 'bundle', path: 'foo'> |
42 >>> url('c:\\\\foo\\\\bar') | |
43 <url path: 'c:\\\\foo\\\\bar'> | |
42 | 44 |
43 Authentication credentials: | 45 Authentication credentials: |
44 | 46 |
45 >>> url('ssh://joe:xyz@x/repo') | 47 >>> url('ssh://joe:xyz@x/repo') |
46 <url scheme: 'ssh', user: 'joe', passwd: 'xyz', host: 'x', path: 'repo'> | 48 <url scheme: 'ssh', user: 'joe', passwd: 'xyz', host: 'x', path: 'repo'> |
61 def __init__(self, path, parse_query=True, parse_fragment=True): | 63 def __init__(self, path, parse_query=True, parse_fragment=True): |
62 # We slowly chomp away at path until we have only the path left | 64 # We slowly chomp away at path until we have only the path left |
63 self.scheme = self.user = self.passwd = self.host = None | 65 self.scheme = self.user = self.passwd = self.host = None |
64 self.port = self.path = self.query = self.fragment = None | 66 self.port = self.path = self.query = self.fragment = None |
65 self._localpath = True | 67 self._localpath = True |
68 | |
69 # special case for Windows drive letters | |
70 if path[1:2] == ':' and path[0:1].isalpha(): | |
71 self.path = path | |
72 return | |
66 | 73 |
67 if not path.startswith('/') and ':' in path: | 74 if not path.startswith('/') and ':' in path: |
68 parts = path.split(':', 1) | 75 parts = path.split(':', 1) |
69 if parts[0]: | 76 if parts[0]: |
70 self.scheme, path = parts | 77 self.scheme, path = parts |