dispatch: move detection of profiling earlier during startup
authorBryan O'Sullivan <bryano@fb.com>
Mon, 13 Feb 2017 20:44:20 -0800
changeset 30933 69a3c6c8bf95
parent 30932 f61c5680a862
child 30934 6d642ecf1a89
dispatch: move detection of profiling earlier during startup
mercurial/dispatch.py
--- a/mercurial/dispatch.py	Mon Feb 13 21:00:50 2017 -0800
+++ b/mercurial/dispatch.py	Mon Feb 13 20:44:20 2017 -0800
@@ -659,6 +659,15 @@
     # imported and commands.table is populated.
     debugcommands.command
 
+    uis = set([ui, lui])
+
+    if req.repo:
+        uis.add(req.repo.ui)
+
+    if '--profile' in args:
+        for ui_ in uis:
+            ui_.setconfig('profiling', 'enabled', 'true', '--profile')
+
     # Configure extensions in phases: uisetup, extsetup, cmdtable, and
     # reposetup. Programs like TortoiseHg will call _dispatch several
     # times so we keep track of configured extensions in _loaded.
@@ -721,21 +730,12 @@
                 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
         atexit.register(print_time)
 
-    uis = set([ui, lui])
-
-    if req.repo:
-        uis.add(req.repo.ui)
-
     if options['verbose'] or options['debug'] or options['quiet']:
         for opt in ('verbose', 'debug', 'quiet'):
             val = str(bool(options[opt]))
             for ui_ in uis:
                 ui_.setconfig('ui', opt, val, '--' + opt)
 
-    if options['profile']:
-        for ui_ in uis:
-            ui_.setconfig('profiling', 'enabled', 'true', '--profile')
-
     if options['traceback']:
         for ui_ in uis:
             ui_.setconfig('ui', 'traceback', 'on', '--traceback')