[PATCH 1 of 3 v2] profiling: allow nested usage of maybeprofile

Yuya Nishihara yuya at tcha.org
Thu Sep 22 07:21:19 EDT 2016


On Thu, 22 Sep 2016 09:04:40 +0000, Arun Kulshreshtha wrote:
> On 9/21/16, 8:51 PM, "Yuya Nishihara" <youjah at gmail.com on behalf of yuya at tcha.org> wrote:
>     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'):
>     
> 
> Yes, in fact this is originally what I had intended to do. However, this would mean that it
> would not be possible to enable profiling from the repo-specific config file.

That's why 'lui' is passed to maybeprofile().


More information about the Mercurial-devel mailing list