Patchwork [6,of,8,V2] perf: omit copying from ui.ferr to ui.fout for Mercurial earlier than 1.9

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Oct. 8, 2016, 4:18 p.m.
Message ID <9478ced7cf3ce3665ce0.1475943506@feefifofum>
Download mbox | patch
Permalink /patch/16947/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Oct. 8, 2016, 4:18 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1475942599 -32400
#      Sun Oct 09 01:03:19 2016 +0900
# Node ID 9478ced7cf3ce3665ce06daba820f3eb2b959f61
# Parent  1fb97069cef8454d4658592e44edbaab11d5e34d
perf: omit copying from ui.ferr to ui.fout for Mercurial earlier than 1.9

Before this patch, referring ui.ferr prevents perf.py from measuring
performance with Mercurial earlier than 1.9 (or 4e1ccd4c2b6d), because
ui.ferr isn't available in such Mercurial, even though there are some
code paths for Mercurial earlier than 1.9 in perf.py.

For example, setting "_prereadsize" attribute in perfindex() and
perfnodelookup() is effective only with hg earlier than 1.8 (or
61c9bc3da402).

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -137,7 +137,11 @@  def gettimer(ui, opts=None):
         opts = {}
     # redirect all to stderr
     ui = ui.copy()
-    ui.fout = ui.ferr
+    uifout = safeattrsetter(ui, 'fout', ignoremissing=True)
+    if uifout:
+        # for "historical portability":
+        # ui.fout/ferr have been available since 1.9 (or 4e1ccd4c2b6d)
+        uifout.set(ui.ferr)
 
     # get a formatter
     uiformatter = getattr(ui, 'formatter', None)