comparison mercurial/dispatch.py @ 30933:69a3c6c8bf95

dispatch: move detection of profiling earlier during startup
author Bryan O'Sullivan <bryano@fb.com>
date Mon, 13 Feb 2017 20:44:20 -0800
parents b35e05103641
children 6d642ecf1a89
comparison
equal deleted inserted replaced
30932:f61c5680a862 30933:69a3c6c8bf95
657 657
658 # Side-effect of accessing is debugcommands module is guaranteed to be 658 # Side-effect of accessing is debugcommands module is guaranteed to be
659 # imported and commands.table is populated. 659 # imported and commands.table is populated.
660 debugcommands.command 660 debugcommands.command
661 661
662 uis = set([ui, lui])
663
664 if req.repo:
665 uis.add(req.repo.ui)
666
667 if '--profile' in args:
668 for ui_ in uis:
669 ui_.setconfig('profiling', 'enabled', 'true', '--profile')
670
662 # Configure extensions in phases: uisetup, extsetup, cmdtable, and 671 # Configure extensions in phases: uisetup, extsetup, cmdtable, and
663 # reposetup. Programs like TortoiseHg will call _dispatch several 672 # reposetup. Programs like TortoiseHg will call _dispatch several
664 # times so we keep track of configured extensions in _loaded. 673 # times so we keep track of configured extensions in _loaded.
665 extensions.loadall(lui) 674 extensions.loadall(lui)
666 exts = [ext for ext in extensions.extensions() if ext[0] not in _loaded] 675 exts = [ext for ext in extensions.extensions() if ext[0] not in _loaded]
719 t = get_times() 728 t = get_times()
720 ui.warn(_("time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") % 729 ui.warn(_("time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") %
721 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) 730 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
722 atexit.register(print_time) 731 atexit.register(print_time)
723 732
724 uis = set([ui, lui])
725
726 if req.repo:
727 uis.add(req.repo.ui)
728
729 if options['verbose'] or options['debug'] or options['quiet']: 733 if options['verbose'] or options['debug'] or options['quiet']:
730 for opt in ('verbose', 'debug', 'quiet'): 734 for opt in ('verbose', 'debug', 'quiet'):
731 val = str(bool(options[opt])) 735 val = str(bool(options[opt]))
732 for ui_ in uis: 736 for ui_ in uis:
733 ui_.setconfig('ui', opt, val, '--' + opt) 737 ui_.setconfig('ui', opt, val, '--' + opt)
734
735 if options['profile']:
736 for ui_ in uis:
737 ui_.setconfig('profiling', 'enabled', 'true', '--profile')
738 738
739 if options['traceback']: 739 if options['traceback']:
740 for ui_ in uis: 740 for ui_ in uis:
741 ui_.setconfig('ui', 'traceback', 'on', '--traceback') 741 ui_.setconfig('ui', 'traceback', 'on', '--traceback')
742 742