[PATCH 5 of 7 V2] profiling: don't error with statprof when profiling has already started
Gregory Szorc
gregory.szorc at gmail.com
Sun Aug 14 21:37:42 EDT 2016
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1471224523 25200
# Sun Aug 14 18:28:43 2016 -0700
# Node ID ef37b1df0058f54c7b23252b7356bb97b07652d7
# Parent fd7b55561853e9d5532f3a9265433a7b614f2687
profiling: don't error with statprof when profiling has already started
statprof.reset() asserts if profiling has already started. So don't
call if it profiling is already running.
diff --git a/mercurial/profiling.py b/mercurial/profiling.py
--- a/mercurial/profiling.py
+++ b/mercurial/profiling.py
@@ -83,17 +83,19 @@ def statprofile(ui, fp):
try:
import statprof
except ImportError:
raise error.Abort(_(
'statprof not available - install using "easy_install statprof"'))
freq = ui.configint('profiling', 'freq', default=1000)
if freq > 0:
- statprof.reset(freq)
+ # Cannot reset when profiler is already active. So silently no-op.
+ if statprof.state.profile_level == 0:
+ statprof.reset(freq)
else:
ui.warn(_("invalid sampling frequency '%s' - ignoring\n") % freq)
statprof.start()
try:
yield
finally:
statprof.stop()
More information about the Mercurial-devel
mailing list