Patchwork [10,of,13,V2] ui: extract buffer write from protect and timed 'write_err' output

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 24, 2017, 10:09 p.m.
Message ID <1a7930c207d7fd664f3d.1487974184@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18764/
State Accepted
Headers show

Comments

Pierre-Yves David - Feb. 24, 2017, 10:09 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1487960925 -3600
#      Fri Feb 24 19:28:45 2017 +0100
# Node ID 1a7930c207d7fd664f3d288974df36e3d8d32fd7
# Parent  85598b639dafeb7c64a8e2219f4095b2197729e1
# EXP-Topic color
ui: extract buffer write from protect and timed 'write_err' output

That subcall to 'self.write' is never doing actual write but only store things
in buffers. So we do not need to protect it for exception not to time its
execution.

This will make it easier to extract a '_write_err' function as we did for
'write'.

Patch

diff -r 85598b639daf -r 1a7930c207d7 mercurial/ui.py
--- a/mercurial/ui.py	Mon Feb 20 12:31:39 2017 +0100
+++ b/mercurial/ui.py	Fri Feb 24 19:28:45 2017 +0100
@@ -822,9 +822,9 @@  class ui(object):
 
     def write_err(self, *args, **opts):
         self._progclear()
+        if self._bufferstates and self._bufferstates[-1][0]:
+            return self.write(*args, **opts)
         try:
-            if self._bufferstates and self._bufferstates[-1][0]:
-                return self.write(*args, **opts)
             with self.timeblockedsection('stdio'):
                 if not getattr(self.fout, 'closed', False):
                     self.fout.flush()