Mercurial > public > mercurial-scm > hg
comparison mercurial/subrepo.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 | ecaa78594983 |
children | 21b8ce4d3331 |
comparison
equal
deleted
inserted
replaced
14075:bc101902a68d | 14076:924c82157d46 |
---|---|
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 import errno, os, re, xml.dom.minidom, shutil, posixpath | 8 import errno, os, re, xml.dom.minidom, shutil, posixpath |
9 import stat, subprocess, tarfile | 9 import stat, subprocess, tarfile |
10 from i18n import _ | 10 from i18n import _ |
11 import config, scmutil, util, node, error, cmdutil, url, bookmarks | 11 import config, scmutil, util, node, error, cmdutil, bookmarks |
12 hg = None | 12 hg = None |
13 propertycache = util.propertycache | 13 propertycache = util.propertycache |
14 | 14 |
15 nullstate = ('', '', 'empty') | 15 nullstate = ('', '', 'empty') |
16 | 16 |
192 | 192 |
193 def _abssource(repo, push=False, abort=True): | 193 def _abssource(repo, push=False, abort=True): |
194 """return pull/push path of repo - either based on parent repo .hgsub info | 194 """return pull/push path of repo - either based on parent repo .hgsub info |
195 or on the top repo config. Abort or return None if no source found.""" | 195 or on the top repo config. Abort or return None if no source found.""" |
196 if hasattr(repo, '_subparent'): | 196 if hasattr(repo, '_subparent'): |
197 source = url.url(repo._subsource) | 197 source = util.url(repo._subsource) |
198 source.path = posixpath.normpath(source.path) | 198 source.path = posixpath.normpath(source.path) |
199 if posixpath.isabs(source.path) or source.scheme: | 199 if posixpath.isabs(source.path) or source.scheme: |
200 return str(source) | 200 return str(source) |
201 parent = _abssource(repo._subparent, push, abort=False) | 201 parent = _abssource(repo._subparent, push, abort=False) |
202 if parent: | 202 if parent: |
203 parent = url.url(parent) | 203 parent = util.url(parent) |
204 parent.path = posixpath.join(parent.path, source.path) | 204 parent.path = posixpath.join(parent.path, source.path) |
205 parent.path = posixpath.normpath(parent.path) | 205 parent.path = posixpath.normpath(parent.path) |
206 return str(parent) | 206 return str(parent) |
207 else: # recursion reached top repo | 207 else: # recursion reached top repo |
208 if hasattr(repo, '_subtoppath'): | 208 if hasattr(repo, '_subtoppath'): |