Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.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 | 72c84f24b420 |
children | 9f5a0acb0056 |
comparison
equal
deleted
inserted
replaced
14075:bc101902a68d | 14076:924c82157d46 |
---|---|
2605 opts.get('branch')) | 2605 opts.get('branch')) |
2606 other = hg.repository(hg.remoteui(repo, opts), source) | 2606 other = hg.repository(hg.remoteui(repo, opts), source) |
2607 if 'bookmarks' not in other.listkeys('namespaces'): | 2607 if 'bookmarks' not in other.listkeys('namespaces'): |
2608 ui.warn(_("remote doesn't support bookmarks\n")) | 2608 ui.warn(_("remote doesn't support bookmarks\n")) |
2609 return 0 | 2609 return 0 |
2610 ui.status(_('comparing with %s\n') % url.hidepassword(source)) | 2610 ui.status(_('comparing with %s\n') % util.hidepassword(source)) |
2611 return bookmarks.diff(ui, repo, other) | 2611 return bookmarks.diff(ui, repo, other) |
2612 | 2612 |
2613 ret = hg.incoming(ui, repo, source, opts) | 2613 ret = hg.incoming(ui, repo, source, opts) |
2614 return ret | 2614 return ret |
2615 | 2615 |
2892 dest, branches = hg.parseurl(dest, opts.get('branch')) | 2892 dest, branches = hg.parseurl(dest, opts.get('branch')) |
2893 other = hg.repository(hg.remoteui(repo, opts), dest) | 2893 other = hg.repository(hg.remoteui(repo, opts), dest) |
2894 if 'bookmarks' not in other.listkeys('namespaces'): | 2894 if 'bookmarks' not in other.listkeys('namespaces'): |
2895 ui.warn(_("remote doesn't support bookmarks\n")) | 2895 ui.warn(_("remote doesn't support bookmarks\n")) |
2896 return 0 | 2896 return 0 |
2897 ui.status(_('comparing with %s\n') % url.hidepassword(dest)) | 2897 ui.status(_('comparing with %s\n') % util.hidepassword(dest)) |
2898 return bookmarks.diff(ui, other, repo) | 2898 return bookmarks.diff(ui, other, repo) |
2899 | 2899 |
2900 ret = hg.outgoing(ui, repo, dest, opts) | 2900 ret = hg.outgoing(ui, repo, dest, opts) |
2901 return ret | 2901 return ret |
2902 | 2902 |
2966 Returns 0 on success. | 2966 Returns 0 on success. |
2967 """ | 2967 """ |
2968 if search: | 2968 if search: |
2969 for name, path in ui.configitems("paths"): | 2969 for name, path in ui.configitems("paths"): |
2970 if name == search: | 2970 if name == search: |
2971 ui.write("%s\n" % url.hidepassword(path)) | 2971 ui.write("%s\n" % util.hidepassword(path)) |
2972 return | 2972 return |
2973 ui.warn(_("not found!\n")) | 2973 ui.warn(_("not found!\n")) |
2974 return 1 | 2974 return 1 |
2975 else: | 2975 else: |
2976 for name, path in ui.configitems("paths"): | 2976 for name, path in ui.configitems("paths"): |
2977 ui.write("%s = %s\n" % (name, url.hidepassword(path))) | 2977 ui.write("%s = %s\n" % (name, util.hidepassword(path))) |
2978 | 2978 |
2979 def postincoming(ui, repo, modheads, optupdate, checkout): | 2979 def postincoming(ui, repo, modheads, optupdate, checkout): |
2980 if modheads == 0: | 2980 if modheads == 0: |
2981 return | 2981 return |
2982 if optupdate: | 2982 if optupdate: |
3015 | 3015 |
3016 Returns 0 on success, 1 if an update had unresolved files. | 3016 Returns 0 on success, 1 if an update had unresolved files. |
3017 """ | 3017 """ |
3018 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) | 3018 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) |
3019 other = hg.repository(hg.remoteui(repo, opts), source) | 3019 other = hg.repository(hg.remoteui(repo, opts), source) |
3020 ui.status(_('pulling from %s\n') % url.hidepassword(source)) | 3020 ui.status(_('pulling from %s\n') % util.hidepassword(source)) |
3021 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) | 3021 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) |
3022 | 3022 |
3023 if opts.get('bookmark'): | 3023 if opts.get('bookmark'): |
3024 if not revs: | 3024 if not revs: |
3025 revs = [] | 3025 revs = [] |
3098 # this lets simultaneous -r, -b options continue working | 3098 # this lets simultaneous -r, -b options continue working |
3099 opts.setdefault('rev', []).append("null") | 3099 opts.setdefault('rev', []).append("null") |
3100 | 3100 |
3101 dest = ui.expandpath(dest or 'default-push', dest or 'default') | 3101 dest = ui.expandpath(dest or 'default-push', dest or 'default') |
3102 dest, branches = hg.parseurl(dest, opts.get('branch')) | 3102 dest, branches = hg.parseurl(dest, opts.get('branch')) |
3103 ui.status(_('pushing to %s\n') % url.hidepassword(dest)) | 3103 ui.status(_('pushing to %s\n') % util.hidepassword(dest)) |
3104 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) | 3104 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) |
3105 other = hg.repository(hg.remoteui(repo, opts), dest) | 3105 other = hg.repository(hg.remoteui(repo, opts), dest) |
3106 if revs: | 3106 if revs: |
3107 revs = [repo.lookup(rev) for rev in revs] | 3107 revs = [repo.lookup(rev) for rev in revs] |
3108 | 3108 |
3917 if opts.get('remote'): | 3917 if opts.get('remote'): |
3918 t = [] | 3918 t = [] |
3919 source, branches = hg.parseurl(ui.expandpath('default')) | 3919 source, branches = hg.parseurl(ui.expandpath('default')) |
3920 other = hg.repository(hg.remoteui(repo, {}), source) | 3920 other = hg.repository(hg.remoteui(repo, {}), source) |
3921 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) | 3921 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) |
3922 ui.debug('comparing with %s\n' % url.hidepassword(source)) | 3922 ui.debug('comparing with %s\n' % util.hidepassword(source)) |
3923 repo.ui.pushbuffer() | 3923 repo.ui.pushbuffer() |
3924 common, incoming, rheads = discovery.findcommonincoming(repo, other) | 3924 common, incoming, rheads = discovery.findcommonincoming(repo, other) |
3925 repo.ui.popbuffer() | 3925 repo.ui.popbuffer() |
3926 if incoming: | 3926 if incoming: |
3927 t.append(_('1 or more incoming')) | 3927 t.append(_('1 or more incoming')) |
3928 | 3928 |
3929 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default')) | 3929 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default')) |
3930 revs, checkout = hg.addbranchrevs(repo, repo, branches, None) | 3930 revs, checkout = hg.addbranchrevs(repo, repo, branches, None) |
3931 other = hg.repository(hg.remoteui(repo, {}), dest) | 3931 other = hg.repository(hg.remoteui(repo, {}), dest) |
3932 ui.debug('comparing with %s\n' % url.hidepassword(dest)) | 3932 ui.debug('comparing with %s\n' % util.hidepassword(dest)) |
3933 repo.ui.pushbuffer() | 3933 repo.ui.pushbuffer() |
3934 common, _anyinc, _heads = discovery.findcommonincoming(repo, other) | 3934 common, _anyinc, _heads = discovery.findcommonincoming(repo, other) |
3935 repo.ui.popbuffer() | 3935 repo.ui.popbuffer() |
3936 o = repo.changelog.findmissing(common=common) | 3936 o = repo.changelog.findmissing(common=common) |
3937 if o: | 3937 if o: |