From patchwork Mon Aug 8 09:59:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [7, of, 8] perf: omit copying from ui.ferr to ui.fout for Mercurial earlier than 1.9 From: Katsunori FUJIWARA X-Patchwork-Id: 16194 Message-Id: <697b11a0c95313d8220f.1470650386@juju> To: mercurial-devel@mercurial-scm.org Date: Mon, 08 Aug 2016 18:59:46 +0900 # HG changeset patch # User FUJIWARA Katsunori # 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)