##// END OF EJS Templates
url: nuke some newly-introduced underbars in identifiers
Matt Mackall -
r13827:f1823b9f default
parent child Browse files
Show More
@@ -71,7 +71,7 b' class ShortRepository(object):'
71 71 url = ''.join(self.templater.process(self.url, context)) + tail
72 72 return hg._lookup(url).instance(ui, url, create)
73 73
74 def has_drive_letter(orig, path):
74 def hasdriveletter(orig, path):
75 75 for scheme in schemes:
76 76 if path.startswith(scheme + ':'):
77 77 return False
@@ -95,4 +95,4 b' def extsetup(ui):'
95 95 'letter %s:\\\n') % (scheme, scheme.upper()))
96 96 hg.schemes[scheme] = ShortRepository(url, scheme, t)
97 97
98 extensions.wrapfunction(urlmod, 'has_drive_letter', has_drive_letter)
98 extensions.wrapfunction(urlmod, 'hasdriveletter', hasdriveletter)
@@ -23,7 +23,7 b' class sshrepository(wireproto.wirereposi'
23 23 self._url = path
24 24 self.ui = ui
25 25
26 u = url.url(path, parse_query=False, parse_fragment=False)
26 u = url.url(path, parsequery=False, parsefragment=False)
27 27 if u.scheme != 'ssh' or not u.host or u.path is None:
28 28 self._abort(error.RepoError(_("couldn't parse location %s") % path))
29 29
@@ -111,7 +111,7 b' class ui(object):'
111 111 % (n, p, self.configsource('paths', n)))
112 112 p = p.replace('%%', '%')
113 113 p = util.expandpath(p)
114 if not url.has_scheme(p) and not os.path.isabs(p):
114 if not url.hasscheme(p) and not os.path.isabs(p):
115 115 p = os.path.normpath(os.path.join(root, p))
116 116 c.set("paths", n, p)
117 117
@@ -325,7 +325,7 b' class ui(object):'
325 325
326 326 def expandpath(self, loc, default=None):
327 327 """Return repository location relative to cwd or from [paths]"""
328 if url.has_scheme(loc) or os.path.isdir(os.path.join(loc, '.hg')):
328 if url.hasscheme(loc) or os.path.isdir(os.path.join(loc, '.hg')):
329 329 return loc
330 330
331 331 path = self.config('paths', loc)
@@ -23,8 +23,8 b' class url(object):'
23 23 Missing components are set to None. The only exception is
24 24 fragment, which is set to '' if present but empty.
25 25
26 If parse_fragment is False, fragment is included in query. If
27 parse_query is False, query is included in path. If both are
26 If parsefragment is False, fragment is included in query. If
27 parsequery is False, query is included in path. If both are
28 28 False, both fragment and query are included in path.
29 29
30 30 See http://www.ietf.org/rfc/rfc2396.txt for more information.
@@ -58,14 +58,14 b' class url(object):'
58 58
59 59 >>> url('http://host/a?b#c')
60 60 <url scheme: 'http', host: 'host', path: 'a', query: 'b', fragment: 'c'>
61 >>> url('http://host/a?b#c', parse_query=False, parse_fragment=False)
61 >>> url('http://host/a?b#c', parsequery=False, parsefragment=False)
62 62 <url scheme: 'http', host: 'host', path: 'a?b#c'>
63 63 """
64 64
65 65 _safechars = "!~*'()+"
66 66 _safepchars = "/!~*'()+"
67 67
68 def __init__(self, path, parse_query=True, parse_fragment=True):
68 def __init__(self, path, parsequery=True, parsefragment=True):
69 69 # We slowly chomp away at path until we have only the path left
70 70 self.scheme = self.user = self.passwd = self.host = None
71 71 self.port = self.path = self.query = self.fragment = None
@@ -74,7 +74,7 b' class url(object):'
74 74 self._origpath = path
75 75
76 76 # special case for Windows drive letters
77 if has_drive_letter(path):
77 if hasdriveletter(path):
78 78 self.path = path
79 79 return
80 80
@@ -100,7 +100,7 b' class url(object):'
100 100 self.path = ''
101 101 return
102 102 else:
103 if parse_fragment and '#' in path:
103 if parsefragment and '#' in path:
104 104 path, self.fragment = path.split('#', 1)
105 105 if not path:
106 106 path = None
@@ -108,7 +108,7 b' class url(object):'
108 108 self.path = path
109 109 return
110 110
111 if parse_query and '?' in path:
111 if parsequery and '?' in path:
112 112 path, self.query = path.split('?', 1)
113 113 if not path:
114 114 path = None
@@ -239,26 +239,26 b' class url(object):'
239 239 path = self.path or '/'
240 240 # For Windows, we need to promote hosts containing drive
241 241 # letters to paths with drive letters.
242 if has_drive_letter(self._hostport):
242 if hasdriveletter(self._hostport):
243 243 path = self._hostport + '/' + self.path
244 244 elif self.host is not None and self.path:
245 245 path = '/' + path
246 246 # We also need to handle the case of file:///C:/, which
247 247 # should return C:/, not /C:/.
248 elif has_drive_letter(path):
248 elif hasdriveletter(path):
249 249 # Strip leading slash from paths with drive names
250 250 return path[1:]
251 251 return path
252 252 return self._origpath
253 253
254 def has_scheme(path):
254 def hasscheme(path):
255 255 return bool(url(path).scheme)
256 256
257 def has_drive_letter(path):
257 def hasdriveletter(path):
258 258 return path[1:2] == ':' and path[0:1].isalpha()
259 259
260 260 def localpath(path):
261 return url(path, parse_query=False, parse_fragment=False).localpath()
261 return url(path, parsequery=False, parsefragment=False).localpath()
262 262
263 263 def hidepassword(u):
264 264 '''hide user credential in a url string'''
@@ -71,11 +71,11 b' def test_url():'
71 71 <url scheme: 'http', host: 'host', path: 'a', fragment: 'b?c'>
72 72 >>> url('http://host/?a#b')
73 73 <url scheme: 'http', host: 'host', path: '', query: 'a', fragment: 'b'>
74 >>> url('http://host/?a#b', parse_query=False)
74 >>> url('http://host/?a#b', parsequery=False)
75 75 <url scheme: 'http', host: 'host', path: '?a', fragment: 'b'>
76 >>> url('http://host/?a#b', parse_fragment=False)
76 >>> url('http://host/?a#b', parsefragment=False)
77 77 <url scheme: 'http', host: 'host', path: '', query: 'a#b'>
78 >>> url('http://host/?a#b', parse_query=False, parse_fragment=False)
78 >>> url('http://host/?a#b', parsequery=False, parsefragment=False)
79 79 <url scheme: 'http', host: 'host', path: '?a#b'>
80 80
81 81 IPv6 addresses:
General Comments 0
You need to be logged in to leave comments. Login now