Show More
@@ -898,21 +898,12 b' def _dispatch(req):' | |||
|
898 | 898 | repo.close() |
|
899 | 899 | |
|
900 | 900 | def _runcommand(ui, options, cmd, cmdfunc): |
|
901 | """Enables the profiler if applicable. | |
|
902 | ||
|
903 | ``profiling.enabled`` - boolean config that enables or disables profiling | |
|
904 | """ | |
|
905 | def checkargs(): | |
|
901 | """Run a command function, possibly with profiling enabled.""" | |
|
902 | with profiling.maybeprofile(ui): | |
|
906 | 903 | try: |
|
907 | 904 | return cmdfunc() |
|
908 | 905 | except error.SignatureError: |
|
909 |
raise error.CommandError(cmd, _( |
|
|
910 | ||
|
911 | if ui.configbool('profiling', 'enabled'): | |
|
912 | with profiling.profile(ui): | |
|
913 | return checkargs() | |
|
914 | else: | |
|
915 | return checkargs() | |
|
906 | raise error.CommandError(cmd, _('invalid arguments')) | |
|
916 | 907 | |
|
917 | 908 | def _exceptionwarning(ui): |
|
918 | 909 | """Produce a warning message for the current active exception""" |
@@ -1393,6 +1393,12 b" collected during profiling, while 'profi" | |||
|
1393 | 1393 | statistical text report generated from the profiling data. The |
|
1394 | 1394 | profiling is done using lsprof. |
|
1395 | 1395 | |
|
1396 | ``enabled`` | |
|
1397 | Enable the profiler. | |
|
1398 | (default: false) | |
|
1399 | ||
|
1400 | This is equivalent to passing ``--profile`` on the command line. | |
|
1401 | ||
|
1396 | 1402 | ``type`` |
|
1397 | 1403 | The type of profiler to use. |
|
1398 | 1404 | (default: ls) |
@@ -143,3 +143,20 b' def profile(ui):' | |||
|
143 | 143 | val = val.replace('%', '%%') |
|
144 | 144 | ui.log('profile', val) |
|
145 | 145 | fp.close() |
|
146 | ||
|
147 | @contextlib.contextmanager | |
|
148 | def maybeprofile(ui): | |
|
149 | """Profile if enabled, else do nothing. | |
|
150 | ||
|
151 | This context manager can be used to optionally profile if profiling | |
|
152 | is enabled. Otherwise, it does nothing. | |
|
153 | ||
|
154 | The purpose of this context manager is to make calling code simpler: | |
|
155 | just use a single code path for calling into code you may want to profile | |
|
156 | and this function determines whether to start profiling. | |
|
157 | """ | |
|
158 | if ui.configbool('profiling', 'enabled'): | |
|
159 | with profile(ui): | |
|
160 | yield | |
|
161 | else: | |
|
162 | yield |
@@ -96,7 +96,6 b'' | |||
|
96 | 96 | */mercurial/dispatch.py:* in _dispatch (glob) |
|
97 | 97 | */mercurial/dispatch.py:* in runcommand (glob) |
|
98 | 98 | */mercurial/dispatch.py:* in _runcommand (glob) |
|
99 | */mercurial/dispatch.py:* in checkargs (glob) | |
|
100 | 99 | */mercurial/dispatch.py:* in <lambda> (glob) |
|
101 | 100 | */mercurial/util.py:* in check (glob) |
|
102 | 101 | $TESTTMP/buggylocking.py:* in buggylocking (glob) |
@@ -132,7 +131,6 b'' | |||
|
132 | 131 | */mercurial/dispatch.py:* in _dispatch (glob) |
|
133 | 132 | */mercurial/dispatch.py:* in runcommand (glob) |
|
134 | 133 | */mercurial/dispatch.py:* in _runcommand (glob) |
|
135 | */mercurial/dispatch.py:* in checkargs (glob) | |
|
136 | 134 | */mercurial/dispatch.py:* in <lambda> (glob) |
|
137 | 135 | */mercurial/util.py:* in check (glob) |
|
138 | 136 | $TESTTMP/buggylocking.py:* in oldanddeprecated (glob) |
@@ -156,7 +154,6 b'' | |||
|
156 | 154 | */mercurial/dispatch.py:* in _dispatch (glob) |
|
157 | 155 | */mercurial/dispatch.py:* in runcommand (glob) |
|
158 | 156 | */mercurial/dispatch.py:* in _runcommand (glob) |
|
159 | */mercurial/dispatch.py:* in checkargs (glob) | |
|
160 | 157 | */mercurial/dispatch.py:* in <lambda> (glob) |
|
161 | 158 | */mercurial/util.py:* in check (glob) |
|
162 | 159 | $TESTTMP/buggylocking.py:* in oldanddeprecated (glob) |
General Comments 0
You need to be logged in to leave comments.
Login now