comparison hgext/color.py @ 21190:2606e7f227f6 stable

color: add missing handling of stderr capture introduced by 350dc24a553d It wouldn't raise exception without this change, but _bufferstates was wrong because of missing _bufferstates.pop() in colorui.popbuffer().
author Yuya Nishihara <yuya@tcha.org>
date Sun, 27 Apr 2014 15:09:48 +0900
parents b775a2029e8d
children 75aaae8ad660
comparison
equal deleted inserted replaced
21189:2a74c5af892f 21190:2606e7f227f6
339 class colorui(uimod.ui): 339 class colorui(uimod.ui):
340 def popbuffer(self, labeled=False): 340 def popbuffer(self, labeled=False):
341 if self._colormode is None: 341 if self._colormode is None:
342 return super(colorui, self).popbuffer(labeled) 342 return super(colorui, self).popbuffer(labeled)
343 343
344 self._bufferstates.pop()
344 if labeled: 345 if labeled:
345 return ''.join(self.label(a, label) for a, label 346 return ''.join(self.label(a, label) for a, label
346 in self._buffers.pop()) 347 in self._buffers.pop())
347 return ''.join(a for a, label in self._buffers.pop()) 348 return ''.join(a for a, label in self._buffers.pop())
348 349
364 def write_err(self, *args, **opts): 365 def write_err(self, *args, **opts):
365 if self._colormode is None: 366 if self._colormode is None:
366 return super(colorui, self).write_err(*args, **opts) 367 return super(colorui, self).write_err(*args, **opts)
367 368
368 label = opts.get('label', '') 369 label = opts.get('label', '')
370 if self._bufferstates and self._bufferstates[-1]:
371 return self.write(*args, **opts)
369 if self._colormode == 'win32': 372 if self._colormode == 'win32':
370 for a in args: 373 for a in args:
371 win32print(a, super(colorui, self).write_err, **opts) 374 win32print(a, super(colorui, self).write_err, **opts)
372 else: 375 else:
373 return super(colorui, self).write_err( 376 return super(colorui, self).write_err(