Show More
@@ -94,9 +94,12 b' class ui(object):' | |||||
94 | def __init__(self, src=None): |
|
94 | def __init__(self, src=None): | |
95 | # _buffers: used for temporary capture of output |
|
95 | # _buffers: used for temporary capture of output | |
96 | self._buffers = [] |
|
96 | self._buffers = [] | |
97 | # _bufferstates: |
|
97 | # 3-tuple describing how each buffer in the stack behaves. | |
98 | # should the temporary capture include stderr and subprocess output |
|
98 | # Values are (capture stderr, capture subprocesses, apply labels). | |
99 | self._bufferstates = [] |
|
99 | self._bufferstates = [] | |
|
100 | # When a buffer is active, defines whether we are expanding labels. | |||
|
101 | # This exists to prevent an extra list lookup. | |||
|
102 | self._bufferapplylabels = None | |||
100 | self.quiet = self.verbose = self.debugflag = self.tracebackflag = False |
|
103 | self.quiet = self.verbose = self.debugflag = self.tracebackflag = False | |
101 | self._reportuntrusted = True |
|
104 | self._reportuntrusted = True | |
102 | self._ocfg = config.config() # overlay |
|
105 | self._ocfg = config.config() # overlay | |
@@ -572,15 +575,24 b' class ui(object):' | |||||
572 | def paths(self): |
|
575 | def paths(self): | |
573 | return paths(self) |
|
576 | return paths(self) | |
574 |
|
577 | |||
575 | def pushbuffer(self, error=False, subproc=False): |
|
578 | def pushbuffer(self, error=False, subproc=False, labeled=False): | |
576 | """install a buffer to capture standard output of the ui object |
|
579 | """install a buffer to capture standard output of the ui object | |
577 |
|
580 | |||
578 | If error is True, the error output will be captured too. |
|
581 | If error is True, the error output will be captured too. | |
579 |
|
582 | |||
580 | If subproc is True, output from subprocesses (typically hooks) will be |
|
583 | If subproc is True, output from subprocesses (typically hooks) will be | |
581 |
captured too. |
|
584 | captured too. | |
|
585 | ||||
|
586 | If labeled is True, any labels associated with buffered | |||
|
587 | output will be handled. By default, this has no effect | |||
|
588 | on the output returned, but extensions and GUI tools may | |||
|
589 | handle this argument and returned styled output. If output | |||
|
590 | is being buffered so it can be captured and parsed or | |||
|
591 | processed, labeled should not be set to True. | |||
|
592 | """ | |||
582 | self._buffers.append([]) |
|
593 | self._buffers.append([]) | |
583 | self._bufferstates.append((error, subproc)) |
|
594 | self._bufferstates.append((error, subproc, labeled)) | |
|
595 | self._bufferapplylabels = labeled | |||
584 |
|
596 | |||
585 | def popbuffer(self, labeled=False): |
|
597 | def popbuffer(self, labeled=False): | |
586 | '''pop the last buffer and return the buffered output |
|
598 | '''pop the last buffer and return the buffered output | |
@@ -593,6 +605,11 b' class ui(object):' | |||||
593 | processed, labeled should not be set to True. |
|
605 | processed, labeled should not be set to True. | |
594 | ''' |
|
606 | ''' | |
595 | self._bufferstates.pop() |
|
607 | self._bufferstates.pop() | |
|
608 | if self._bufferstates: | |||
|
609 | self._bufferapplylabels = self._bufferstates[-1][2] | |||
|
610 | else: | |||
|
611 | self._bufferapplylabels = None | |||
|
612 | ||||
596 | return "".join(self._buffers.pop()) |
|
613 | return "".join(self._buffers.pop()) | |
597 |
|
614 | |||
598 | def write(self, *args, **opts): |
|
615 | def write(self, *args, **opts): |
General Comments 0
You need to be logged in to leave comments.
Login now