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.
--- a/contrib/perf.py Mon Nov 14 15:24:07 2016 -0800
+++ b/contrib/perf.py Tue Nov 15 16:10:57 2016 +0100
@@ -136,13 +136,14 @@
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)