comparison mercurial/httprepo.py @ 14076:924c82157d46

url: move URL parsing functions into util to improve startup time The introduction of the new URL parsing code has created a startup time regression. This is mainly due to the use of url.hasscheme() in the ui class. It ends up importing many libraries that the url module requires. This fix helps marginally, but if we can get rid of the urllib import in the URL parser all together, startup time will go back to normal. perfstartup time before the URL refactoring (8796fb6af67e): ! wall 0.050692 comb 0.000000 user 0.000000 sys 0.000000 (best of 100) current startup time (139fb11210bb): ! wall 0.070685 comb 0.000000 user 0.000000 sys 0.000000 (best of 100) after this change: ! wall 0.064667 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)
author Brodie Rao <brodie@bitheap.org>
date Sat, 30 Apr 2011 09:43:20 -0700
parents aaa9a5989405
children ce99d887585f
comparison
equal deleted inserted replaced
14075:bc101902a68d 14076:924c82157d46
26 class httprepository(wireproto.wirerepository): 26 class httprepository(wireproto.wirerepository):
27 def __init__(self, ui, path): 27 def __init__(self, ui, path):
28 self.path = path 28 self.path = path
29 self.caps = None 29 self.caps = None
30 self.handler = None 30 self.handler = None
31 u = url.url(path) 31 u = util.url(path)
32 if u.query or u.fragment: 32 if u.query or u.fragment:
33 raise util.Abort(_('unsupported URL component: "%s"') % 33 raise util.Abort(_('unsupported URL component: "%s"') %
34 (u.query or u.fragment)) 34 (u.query or u.fragment))
35 35
36 # urllib cannot handle URLs with embedded user or passwd 36 # urllib cannot handle URLs with embedded user or passwd
109 try: 109 try:
110 proto = resp.getheader('content-type') 110 proto = resp.getheader('content-type')
111 except AttributeError: 111 except AttributeError:
112 proto = resp.headers['content-type'] 112 proto = resp.headers['content-type']
113 113
114 safeurl = url.hidepassword(self._url) 114 safeurl = util.hidepassword(self._url)
115 # accept old "text/plain" and "application/hg-changegroup" for now 115 # accept old "text/plain" and "application/hg-changegroup" for now
116 if not (proto.startswith('application/mercurial-') or 116 if not (proto.startswith('application/mercurial-') or
117 proto.startswith('text/plain') or 117 proto.startswith('text/plain') or
118 proto.startswith('application/hg-changegroup')): 118 proto.startswith('application/hg-changegroup')):
119 self.ui.debug("requested URL: '%s'\n" % url.hidepassword(cu)) 119 self.ui.debug("requested URL: '%s'\n" % util.hidepassword(cu))
120 raise error.RepoError( 120 raise error.RepoError(
121 _("'%s' does not appear to be an hg repository:\n" 121 _("'%s' does not appear to be an hg repository:\n"
122 "---%%<--- (%s)\n%s\n---%%<---\n") 122 "---%%<--- (%s)\n%s\n---%%<---\n")
123 % (safeurl, proto, resp.read())) 123 % (safeurl, proto, resp.read()))
124 124