Mercurial > public > mercurial-scm > hg
comparison mercurial/dispatch.py @ 30006:b19c2679289c
dispatch: make hg --profile wrap reposetup
Move profiling.maybeprofile() from _runcommand to _dispatch() so that
profiler output will include reposetup.
author | Arun Kulshreshtha <kulshrax@fb.com> |
---|---|
date | Thu, 22 Sep 2016 12:36:30 -0700 |
parents | dfd97e60044c |
children | 869d660b8669 |
comparison
equal
deleted
inserted
replaced
30005:dfd97e60044c | 30006:b19c2679289c |
---|---|
772 | 772 |
773 # All aliases and commands are completely defined, now. | 773 # All aliases and commands are completely defined, now. |
774 # Check abbreviation/ambiguity of shell alias. | 774 # Check abbreviation/ambiguity of shell alias. |
775 shellaliasfn = _checkshellalias(lui, ui, args) | 775 shellaliasfn = _checkshellalias(lui, ui, args) |
776 if shellaliasfn: | 776 if shellaliasfn: |
777 return shellaliasfn() | 777 with profiling.maybeprofile(lui): |
778 return shellaliasfn() | |
778 | 779 |
779 # check for fallback encoding | 780 # check for fallback encoding |
780 fallback = lui.config('ui', 'fallbackencoding') | 781 fallback = lui.config('ui', 'fallbackencoding') |
781 if fallback: | 782 if fallback: |
782 encoding.fallbackencoding = fallback | 783 encoding.fallbackencoding = fallback |
842 if options['help']: | 843 if options['help']: |
843 return commands.help_(ui, cmd, command=cmd is not None) | 844 return commands.help_(ui, cmd, command=cmd is not None) |
844 elif not cmd: | 845 elif not cmd: |
845 return commands.help_(ui, 'shortlist') | 846 return commands.help_(ui, 'shortlist') |
846 | 847 |
847 if True: | 848 with profiling.maybeprofile(lui): |
848 repo = None | 849 repo = None |
849 cmdpats = args[:] | 850 cmdpats = args[:] |
850 if not _cmdattr(ui, cmd, func, 'norepo'): | 851 if not _cmdattr(ui, cmd, func, 'norepo'): |
851 # use the repo from the request only if we don't have -R | 852 # use the repo from the request only if we don't have -R |
852 if not rpath and not cwd: | 853 if not rpath and not cwd: |
902 if repo and repo != req.repo: | 903 if repo and repo != req.repo: |
903 repo.close() | 904 repo.close() |
904 | 905 |
905 def _runcommand(ui, options, cmd, cmdfunc): | 906 def _runcommand(ui, options, cmd, cmdfunc): |
906 """Run a command function, possibly with profiling enabled.""" | 907 """Run a command function, possibly with profiling enabled.""" |
907 with profiling.maybeprofile(ui): | 908 try: |
908 try: | 909 return cmdfunc() |
909 return cmdfunc() | 910 except error.SignatureError: |
910 except error.SignatureError: | 911 raise error.CommandError(cmd, _('invalid arguments')) |
911 raise error.CommandError(cmd, _('invalid arguments')) | |
912 | 912 |
913 def _exceptionwarning(ui): | 913 def _exceptionwarning(ui): |
914 """Produce a warning message for the current active exception""" | 914 """Produce a warning message for the current active exception""" |
915 | 915 |
916 # For compatibility checking, we discard the portion of the hg | 916 # For compatibility checking, we discard the portion of the hg |