Show More
@@ -12,7 +12,10 b' from node import hex' | |||||
12 |
|
12 | |||
13 | class ui(object): |
|
13 | class ui(object): | |
14 | def __init__(self, src=None): |
|
14 | def __init__(self, src=None): | |
|
15 | # _buffers: used for temporary capture of output | |||
15 | self._buffers = [] |
|
16 | self._buffers = [] | |
|
17 | # _bufferstates: Should the temporary capture includes stderr | |||
|
18 | self._bufferstates = [] | |||
16 | self.quiet = self.verbose = self.debugflag = self.tracebackflag = False |
|
19 | self.quiet = self.verbose = self.debugflag = self.tracebackflag = False | |
17 | self._reportuntrusted = True |
|
20 | self._reportuntrusted = True | |
18 | self._ocfg = config.config() # overlay |
|
21 | self._ocfg = config.config() # overlay | |
@@ -471,8 +474,12 b' class ui(object):' | |||||
471 | path = self.config('paths', default) |
|
474 | path = self.config('paths', default) | |
472 | return path or loc |
|
475 | return path or loc | |
473 |
|
476 | |||
474 | def pushbuffer(self): |
|
477 | def pushbuffer(self, error=False): | |
|
478 | """install a buffer to capture standar output of the ui object | |||
|
479 | ||||
|
480 | If error is True, the error output will be captured too.""" | |||
475 | self._buffers.append([]) |
|
481 | self._buffers.append([]) | |
|
482 | self._bufferstates.append(error) | |||
476 |
|
483 | |||
477 | def popbuffer(self, labeled=False): |
|
484 | def popbuffer(self, labeled=False): | |
478 | '''pop the last buffer and return the buffered output |
|
485 | '''pop the last buffer and return the buffered output | |
@@ -484,6 +491,7 b' class ui(object):' | |||||
484 | is being buffered so it can be captured and parsed or |
|
491 | is being buffered so it can be captured and parsed or | |
485 | processed, labeled should not be set to True. |
|
492 | processed, labeled should not be set to True. | |
486 | ''' |
|
493 | ''' | |
|
494 | self._bufferstates.pop() | |||
487 | return "".join(self._buffers.pop()) |
|
495 | return "".join(self._buffers.pop()) | |
488 |
|
496 | |||
489 | def write(self, *args, **opts): |
|
497 | def write(self, *args, **opts): | |
@@ -511,6 +519,8 b' class ui(object):' | |||||
511 |
|
519 | |||
512 | def write_err(self, *args, **opts): |
|
520 | def write_err(self, *args, **opts): | |
513 | try: |
|
521 | try: | |
|
522 | if self._bufferstates and self._bufferstates[-1]: | |||
|
523 | return self.write(*args, **opts) | |||
514 | if not getattr(self.fout, 'closed', False): |
|
524 | if not getattr(self.fout, 'closed', False): | |
515 | self.fout.flush() |
|
525 | self.fout.flush() | |
516 | for a in args: |
|
526 | for a in args: |
General Comments 0
You need to be logged in to leave comments.
Login now