Kiln » Kiln Storage Service Read More
Clone URL:  
emptyui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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