Mercurial > hg
comparison mercurial/util.py @ 9996:2770d03ae49f stable
handle file URIs correctly, according to RFC 2396 (issue1153)
The new code aims to implement the RFC correctly for file URIs.
Previously they were handled incorrectly in several ways, which
could cause problem on Windows in particular.
author | Sune Foldager <cryo@cyanite.org> |
---|---|
date | Thu, 03 Dec 2009 11:06:55 +0100 |
parents | 092bcf431562 |
children | 29e3c4a7699b 25e572394f5c |
comparison
equal
deleted
inserted
replaced
9995:eba6c8687fd2 | 9996:2770d03ae49f |
---|---|
1195 def drop_scheme(scheme, path): | 1195 def drop_scheme(scheme, path): |
1196 sc = scheme + ':' | 1196 sc = scheme + ':' |
1197 if path.startswith(sc): | 1197 if path.startswith(sc): |
1198 path = path[len(sc):] | 1198 path = path[len(sc):] |
1199 if path.startswith('//'): | 1199 if path.startswith('//'): |
1200 path = path[2:] | 1200 if scheme == 'file': |
1201 i = path.find('/', 2) | |
1202 if i == -1: | |
1203 return '' | |
1204 # On Windows, absolute paths are rooted at the current drive | |
1205 # root. On POSIX they are rooted at the file system root. | |
1206 if os.name == 'nt': | |
1207 droot = os.path.splitdrive(os.getcwd())[0] + '/' | |
1208 path = os.path.join(droot, path[i+1:]) | |
1209 else: | |
1210 path = path[i:] | |
1211 else: | |
1212 path = path[2:] | |
1201 return path | 1213 return path |
1202 | 1214 |
1203 def uirepr(s): | 1215 def uirepr(s): |
1204 # Avoid double backslash in Windows path repr() | 1216 # Avoid double backslash in Windows path repr() |
1205 return repr(s).replace('\\\\', '\\') | 1217 return repr(s).replace('\\\\', '\\') |