comparison mercurial/ui.py @ 31109:cb759f7f940d

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'.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 24 Feb 2017 19:28:45 +0100
parents ad074f900907
children 15d6488554b9
comparison
equal deleted inserted replaced
31108:ad074f900907 31109:cb759f7f940d
820 self._blockedtimes['stdio_blocked'] += \ 820 self._blockedtimes['stdio_blocked'] += \
821 (util.timer() - starttime) * 1000 821 (util.timer() - starttime) * 1000
822 822
823 def write_err(self, *args, **opts): 823 def write_err(self, *args, **opts):
824 self._progclear() 824 self._progclear()
825 if self._bufferstates and self._bufferstates[-1][0]:
826 return self.write(*args, **opts)
825 try: 827 try:
826 if self._bufferstates and self._bufferstates[-1][0]:
827 return self.write(*args, **opts)
828 with self.timeblockedsection('stdio'): 828 with self.timeblockedsection('stdio'):
829 if not getattr(self.fout, 'closed', False): 829 if not getattr(self.fout, 'closed', False):
830 self.fout.flush() 830 self.fout.flush()
831 for a in args: 831 for a in args:
832 self.ferr.write(a) 832 self.ferr.write(a)