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

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Mon Aug 8 05:59:46 EDT 2016


# HG changeset patch
# User FUJIWARA Katsunori <foozy at 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).

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)


More information about the Mercurial-devel mailing list