Patchwork [8,of,8,v4] histedit: log the time taken to read in the commands list

login
register
mail settings
Submitter Simon Farnsworth
Date Feb. 13, 2017, 5:29 p.m.
Message ID <b7557fd38e32b4d82b99.1487006948@devvm022.lla2.facebook.com>
Download mbox | patch
Permalink /patch/18452/
State Changes Requested
Headers show

Comments

Simon Farnsworth - Feb. 13, 2017, 5:29 p.m.
# HG changeset patch
# User Simon Farnsworth <simonfar@fb.com>
# Date 1486994849 28800
#      Mon Feb 13 06:07:29 2017 -0800
# Node ID b7557fd38e32b4d82b992003a242cd2a7c9496c5
# Parent  0727b4d77849fbefbf1ce1de6d9fe22ad2c5e1bd
histedit: log the time taken to read in the commands list

If we're being fed an external command list (histedit --commands), then the
time spent reading that file is out of our control. Log it.
Bryan O'Sullivan - Feb. 13, 2017, 6:03 p.m.
On Mon, Feb 13, 2017 at 9:29 AM, Simon Farnsworth <simonfar@fb.com> wrote:

> histedit: log the time taken to read in the commands list
>
> If we're being fed an external command list (histedit --commands), then the
> time spent reading that file is out of our control. Log it.
>

I don't think it's worth measuring this, and this patch can reasonably be
dropped.
Simon Farnsworth - Feb. 13, 2017, 6:18 p.m.
On 13/02/2017 18:03, Bryan O'Sullivan wrote:
>
> On Mon, Feb 13, 2017 at 9:29 AM, Simon Farnsworth <simonfar@fb.com
> <mailto:simonfar@fb.com>> wrote:
>
>     histedit: log the time taken to read in the commands list
>
>     If we're being fed an external command list (histedit --commands),
>     then the
>     time spent reading that file is out of our control. Log it.
>
>
> I don't think it's worth measuring this, and this patch can reasonably
> be dropped.

I disagree, because the external list can also be fed from stdin.

I'll beef up this commit message to make it clearer.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -991,11 +991,12 @@ 
     return goalnew
 
 def _readfile(ui, path):
-    if path == '-':
-        return ui.fin.read()
-    else:
-        with open(path, 'rb') as f:
-            return f.read()
+    with ui.timeblockedsection('histedit'):
+        if path == '-':
+            return ui.fin.read()
+        else:
+            with open(path, 'rb') as f:
+                return f.read()
 
 def _validateargs(ui, repo, state, freeargs, opts, goal, rules, revs):
     # TODO only abort if we try to histedit mq patches, not just