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

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Aug. 8, 2016, 9:59 a.m.
Message ID <697b11a0c95313d8220f.1470650386@juju>
Download mbox | patch
Permalink /patch/16194/
State Changes Requested
Delegated to: Yuya Nishihara
Headers show

Comments

Katsunori FUJIWARA - Aug. 8, 2016, 9:59 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1470649698 -32400
#      Mon Aug 08 18:48:18 2016 +0900
# Node ID 697b11a0c95313d8220f6b5a1f570125c85e3e43
# Parent  06bb7745a1d6e54bfc1e320ced38cd03d40e66ff
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.

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
@@ -136,7 +136,11 @@  def gettimer(ui, opts=None):
         opts = {}
     # redirect all to stderr
     ui = ui.copy()
-    ui.fout = ui.ferr
+    setuifout = safeattrsetter(ui, 'fout', ignoremissing=True)
+    if setuifout:
+        # for "historical portability":
+        # ui.fout/ferr have been available since 1.9 (or 4e1ccd4c2b6d)
+        setuifout(ui.ferr)
 
     # get a formatter
     uiformatter = getattr(ui, 'formatter', None)