mercurial/dispatch.py
changeset 32787 545f69cd6042
parent 32687 12941a782928
child 32788 eede022fc142
--- a/mercurial/dispatch.py	Fri Jun 09 11:42:45 2017 +0100
+++ b/mercurial/dispatch.py	Fri Jun 09 12:36:07 2017 +0100
@@ -764,7 +764,7 @@
         for ui_ in uis:
             ui_.setconfig('profiling', 'enabled', 'true', '--profile')
 
-    with profiling.maybeprofile(lui):
+    with profiling.maybeprofile(lui) as profiler:
         # 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.
@@ -827,6 +827,8 @@
                     _("time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") %
                     (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
             ui.atexit(print_time)
+        if options["profile"]:
+            profiler.start()
 
         if options['verbose'] or options['debug'] or options['quiet']:
             for opt in ('verbose', 'debug', 'quiet'):