Patchwork [1,of,4] statprof: return state from stop()

login
register
mail settings
Submitter Gregory Szorc
Date Nov. 5, 2016, 4:53 a.m.
Message ID <cffcf1865da6bdeb0a59.1478321620@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/17345/
State Accepted
Headers show

Comments

Gregory Szorc - Nov. 5, 2016, 4:53 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1478316157 25200
#      Fri Nov 04 20:22:37 2016 -0700
# Node ID cffcf1865da6bdeb0a59de9ac00c563bbadf1a9b
# Parent  d06c049695e6ad3219e7479c65ce98a2f123e878
statprof: return state from stop()

I don't like global variables. Have stop() return the captured
state so callers can pass data to the display function.
Pierre-Yves David - Nov. 5, 2016, 8:13 p.m.
On 11/05/2016 05:53 AM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1478316157 25200
> #      Fri Nov 04 20:22:37 2016 -0700
> # Node ID cffcf1865da6bdeb0a59de9ac00c563bbadf1a9b
> # Parent  d06c049695e6ad3219e7479c65ce98a2f123e878
> statprof: return state from stop()
>
> I don't like global variables. Have stop() return the captured
> state so callers can pass data to the display function.

Patch 1 is pushed thanks.

Cheers,

Patch

diff --git a/mercurial/statprof.py b/mercurial/statprof.py
--- a/mercurial/statprof.py
+++ b/mercurial/statprof.py
@@ -324,6 +324,8 @@  def stop():
         if statprofpath:
             save_data(statprofpath)
 
+    return state
+
 def save_data(path):
     with open(path, 'w+') as file:
         file.write(str(state.accumulated_time) + '\n')