[PATCH 1 of 2 V3] perf: omit copying ui and redirect to ferr if buffer API is in use
Philippe Pepiot
philippe.pepiot at logilab.fr
Tue Nov 15 15:55:33 UTC 2016
# HG changeset patch
# User Philippe Pepiot <philippe.pepiot at logilab.fr>
# Date 1479222657 -3600
# Tue Nov 15 16:10:57 2016 +0100
# Node ID ab6e50ddc2c56dcf170991293005be6d6f80a232
# Parent e1d6aa0e4c3aed73e0dc523b8a8fd5f9fe23510a
perf: omit copying ui and redirect to ferr if buffer API is in use
This allow to get the output of contrib/perf.py commands using the
ui.pushbuffer() API.
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -136,13 +136,14 @@ def gettimer(ui, opts=None):
if opts is None:
opts = {}
- # redirect all to stderr
- ui = ui.copy()
- 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)
+ # redirect all to stderr unless buffer api is in use
+ if not ui._buffers:
+ ui = ui.copy()
+ 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)
More information about the Mercurial-devel
mailing list