# Copyright (C) 2008-2010 Fog Creek Software. All rights reserved.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2, incorporated herein by reference.
from mercurial import ui
import traceback
from bugzscout import report_error
class emptyui(ui.ui):
def __init__(self, src=None, suppressoutput=True):
super(emptyui, self).__init__(src)
if isinstance(src, emptyui):
self.suppressoutput = src.suppressoutput
else:
self.suppressoutput = suppressoutput
if self.suppressoutput:
self.pushbuffer()
# Wrap the ui's write functions because writing to stdout causes an exception.
# Save the output using a buffer and create a bug from it later (essentially
# catch the error then report it).
def write_err(self, *args, **opts):
return self.write(*args, **opts)
def write(self, *args, **opts):
super(emptyui, self).write(*args, **opts)
if self.suppressoutput:
if len(self._buffers) == 1:
super(emptyui, self).write('\n'.join(traceback.format_stack()) + '\n')
def __del__(self):
if self.suppressoutput:
buffer = self.popbuffer()
if buffer:
report_error('Mercurial output error.', buffer)
try:
super(emptyui, self).__del__()
except AttributeError:
pass
def readconfig(self, *args, **kwargs):
pass
|
Loading...