Mercurial > hg
comparison mercurial/dispatch.py @ 32787:545f69cd6042
profile: support --profile in alias and abbreviated version (--prof)
We now process the "--profile" a second time after alias has been processed and
the command argument fully parsed. If appropriate we enable profiling at that
time.
In these situation, the --profile will cover less than if the full --profile
flag was passed on the command line. This is better than the previous behavior
(flag ignored) and still fullfil multiple valid usecases.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 09 Jun 2017 12:36:07 +0100 |
parents | 12941a782928 |
children | eede022fc142 |
comparison
equal
deleted
inserted
replaced
32786:0ead06d54ffe | 32787:545f69cd6042 |
---|---|
762 | 762 |
763 if '--profile' in args: | 763 if '--profile' in args: |
764 for ui_ in uis: | 764 for ui_ in uis: |
765 ui_.setconfig('profiling', 'enabled', 'true', '--profile') | 765 ui_.setconfig('profiling', 'enabled', 'true', '--profile') |
766 | 766 |
767 with profiling.maybeprofile(lui): | 767 with profiling.maybeprofile(lui) as profiler: |
768 # Configure extensions in phases: uisetup, extsetup, cmdtable, and | 768 # Configure extensions in phases: uisetup, extsetup, cmdtable, and |
769 # reposetup. Programs like TortoiseHg will call _dispatch several | 769 # reposetup. Programs like TortoiseHg will call _dispatch several |
770 # times so we keep track of configured extensions in _loaded. | 770 # times so we keep track of configured extensions in _loaded. |
771 extensions.loadall(lui) | 771 extensions.loadall(lui) |
772 exts = [ext for ext in extensions.extensions() if ext[0] not in _loaded] | 772 exts = [ext for ext in extensions.extensions() if ext[0] not in _loaded] |
825 t = get_times() | 825 t = get_times() |
826 ui.warn( | 826 ui.warn( |
827 _("time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") % | 827 _("time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") % |
828 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) | 828 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) |
829 ui.atexit(print_time) | 829 ui.atexit(print_time) |
830 if options["profile"]: | |
831 profiler.start() | |
830 | 832 |
831 if options['verbose'] or options['debug'] or options['quiet']: | 833 if options['verbose'] or options['debug'] or options['quiet']: |
832 for opt in ('verbose', 'debug', 'quiet'): | 834 for opt in ('verbose', 'debug', 'quiet'): |
833 val = str(bool(options[opt])) | 835 val = str(bool(options[opt])) |
834 if pycompat.ispy3: | 836 if pycompat.ispy3: |