Patchwork [2,of,2,v4] dispatch: make hg --profile wrap reposetup

login
register
mail settings
Submitter Arun Kulshreshtha
Date Sept. 22, 2016, 7:45 p.m.
Message ID <921577f5e9bfc3c059a8.1474573526@dev10559.prn2.facebook.com>
Download mbox | patch
Permalink /patch/16766/
State Accepted
Headers show

Comments

Arun Kulshreshtha - Sept. 22, 2016, 7:45 p.m.
# HG changeset patch
# User Arun Kulshreshtha <kulshrax@fb.com>
# Date 1474572990 25200
#      Thu Sep 22 12:36:30 2016 -0700
# Node ID 921577f5e9bfc3c059a8eb357796736f9edbdcd0
# Parent  75b224273359ed924528491efb88c612f3caa4ca
dispatch: make hg --profile wrap reposetup

Move profiling.maybeprofile() from _runcommand to _dispatch() so that
profiler output will include reposetup.
Yuya Nishihara - Sept. 23, 2016, 12:49 p.m.
On Thu, 22 Sep 2016 12:45:26 -0700, Arun Kulshreshtha wrote:
> # HG changeset patch
> # User Arun Kulshreshtha <kulshrax@fb.com>
> # Date 1474572990 25200
> #      Thu Sep 22 12:36:30 2016 -0700
> # Node ID 921577f5e9bfc3c059a8eb357796736f9edbdcd0
> # Parent  75b224273359ed924528491efb88c612f3caa4ca
> dispatch: make hg --profile wrap reposetup

> @@ -844,7 +845,7 @@
>      elif not cmd:
>          return commands.help_(ui, 'shortlist')
>  
> -    if True:
> +    with profiling.maybeprofile(lui):
>          repo = None
>          cmdpats = args[:]
>          if not _cmdattr(ui, cmd, func, 'norepo'):

As a follow-up patch, maybe we should move --version and --help to
maybeprofile() block.

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -774,7 +774,8 @@ 
     # 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,7 +845,7 @@ 
     elif not cmd:
         return commands.help_(ui, 'shortlist')
 
-    if True:
+    with profiling.maybeprofile(lui):
         repo = None
         cmdpats = args[:]
         if not _cmdattr(ui, cmd, func, 'norepo'):
@@ -904,11 +905,10 @@ 
 
 def _runcommand(ui, options, cmd, cmdfunc):
     """Run a command function, possibly with profiling enabled."""
-    with profiling.maybeprofile(ui):
-        try:
-            return cmdfunc()
-        except error.SignatureError:
-            raise error.CommandError(cmd, _('invalid arguments'))
+    try:
+        return cmdfunc()
+    except error.SignatureError:
+        raise error.CommandError(cmd, _('invalid arguments'))
 
 def _exceptionwarning(ui):
     """Produce a warning message for the current active exception"""