perf: omit copying ui and redirect to ferr if buffer API is in use
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Tue, 15 Nov 2016 16:10:57 +0100
changeset 30405 e77e8876886f
parent 30404 a1beadaa4061
child 30406 cff0f5926797
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.
contrib/perf.py
--- 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)