[PATCH 1 of 2] dispatch: move detection of profiling earlier during startup

Bryan O'Sullivan bos at serpentine.com
Tue Feb 14 04:50:10 UTC 2017


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1487047460 28800
#      Mon Feb 13 20:44:20 2017 -0800
# Node ID 82467bdb090b2500a97ae92e239bcdf72974f3f7
# Parent  a0e3d808690d57d1c9dff840e0b8ee099526397b
dispatch: move detection of profiling earlier during startup

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -655,6 +655,15 @@ def _dispatch(req):
     rpath = _earlygetopt(["-R", "--repository", "--repo"], args)
     path, lui = _getlocal(ui, rpath)
 
+    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 @@ def _dispatch(req):
                 (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')


More information about the Mercurial-devel mailing list