From patchwork Mon Aug 15 01:37:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [5, of, 7, V2] profiling: don't error with statprof when profiling has already started From: Gregory Szorc X-Patchwork-Id: 16299 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sun, 14 Aug 2016 18:37:42 -0700 # HG changeset patch # User Gregory Szorc # 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()