comparison mercurial/ui.py @ 31111:0c003943134f

color: move 'write-err' logic to the core ui class This is similar to what we needed for 'write', we move the logic from the extension to the core class. Beside the dispatch to 'win32print', we just apply label to the argument.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 20 Feb 2017 12:42:23 +0100
parents 15d6488554b9
children a185b903bda3
comparison
equal deleted inserted replaced
31110:15d6488554b9 31111:0c003943134f
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]: 825 if self._bufferstates and self._bufferstates[-1][0]:
826 return self.write(*args, **opts) 826 self.write(*args, **opts)
827 self._write_err(*args, **opts) 827 elif self._colormode == 'win32':
828 # windows color printing is its own can of crab, defer to
829 # the color module and that is it.
830 color.win32print(self._write_err, *args, **opts)
831 else:
832 msgs = args
833 if self._colormode is not None:
834 label = opts.get('label', '')
835 msgs = [self.label(a, label) for a in args]
836 self._write_err(*msgs, **opts)
828 837
829 def _write_err(self, *msgs, **opts): 838 def _write_err(self, *msgs, **opts):
830 try: 839 try:
831 with self.timeblockedsection('stdio'): 840 with self.timeblockedsection('stdio'):
832 if not getattr(self.fout, 'closed', False): 841 if not getattr(self.fout, 'closed', False):