Show More
@@ -94,9 +94,12 b' class ui(object):' | |||
|
94 | 94 | def __init__(self, src=None): |
|
95 | 95 | # _buffers: used for temporary capture of output |
|
96 | 96 | self._buffers = [] |
|
97 | # _bufferstates: | |
|
98 | # should the temporary capture include stderr and subprocess output | |
|
97 | # 3-tuple describing how each buffer in the stack behaves. | |
|
98 | # Values are (capture stderr, capture subprocesses, apply labels). | |
|
99 | 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 | 103 | self.quiet = self.verbose = self.debugflag = self.tracebackflag = False |
|
101 | 104 | self._reportuntrusted = True |
|
102 | 105 | self._ocfg = config.config() # overlay |
@@ -572,15 +575,24 b' class ui(object):' | |||
|
572 | 575 | def paths(self): |
|
573 | 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 | 579 | """install a buffer to capture standard output of the ui object |
|
577 | 580 | |
|
578 | 581 | If error is True, the error output will be captured too. |
|
579 | 582 | |
|
580 | 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 | 593 | self._buffers.append([]) |
|
583 | self._bufferstates.append((error, subproc)) | |
|
594 | self._bufferstates.append((error, subproc, labeled)) | |
|
595 | self._bufferapplylabels = labeled | |
|
584 | 596 | |
|
585 | 597 | def popbuffer(self, labeled=False): |
|
586 | 598 | '''pop the last buffer and return the buffered output |
@@ -593,6 +605,11 b' class ui(object):' | |||
|
593 | 605 | processed, labeled should not be set to True. |
|
594 | 606 | ''' |
|
595 | 607 | self._bufferstates.pop() |
|
608 | if self._bufferstates: | |
|
609 | self._bufferapplylabels = self._bufferstates[-1][2] | |
|
610 | else: | |
|
611 | self._bufferapplylabels = None | |
|
612 | ||
|
596 | 613 | return "".join(self._buffers.pop()) |
|
597 | 614 | |
|
598 | 615 | def write(self, *args, **opts): |
General Comments 0
You need to be logged in to leave comments.
Login now