On Wed, 21 Sep 2016 18:07:57 +0000, Arun Kulshreshtha wrote:
> On 9/21/16, 7:41 AM, "Yuya Nishihara" <y...@tcha.org> wrote:
>     > maybeprofile() can be called in threads. If we need to prevent nesting, 
> we'll
>     > have to save the flag in TLS.
>     
>     That said, I'm not sure if nested maybeprofile() can be noop. Last time, 
> Greg
>     tried to make statprof stackable, which would imply maybeprofile() 
> designed
>     to be nested.
>     
> Hm, right now it seems like if you stack profilers, you’ll get multiple 
> profiling statistics printouts at the end of command execution, which is hard 
> to read. But this this behavior is actually desirable, then we’ll need to 
> deal with this situation differently.

Perhaps we can move both maybeprofile() calls to _dispatch() without thinking
about how nested profilers behave.

--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -774,7 +774,8 @@ def _dispatch(req):
     # Check abbreviation/ambiguity of shell alias.
     shellaliasfn = _checkshellalias(lui, ui, args)
     if shellaliasfn:
-        return shellaliasfn()
+        with profiling.maybeprofile(lui):
+            return shellaliasfn()
 
     # check for fallback encoding
     fallback = lui.config('ui', 'fallbackencoding')
@@ -844,6 +845,10 @@ def _dispatch(req):
     elif not cmd:
         return commands.help_(ui, 'shortlist')
 
+    with profiling.maybeprofile(lui):
+        return _dispatchcommand(...)
+
+def _dispatchcommand(...):
     repo = None
     cmdpats = args[:]
     if not _cmdattr(ui, cmd, func, 'norepo'):
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to