Show More
@@ -51,6 +51,9 b' from mercurial import util' | |||||
51 | def spacejoin(*args): |
|
51 | def spacejoin(*args): | |
52 | return ' '.join(s for s in args if s) |
|
52 | return ' '.join(s for s in args if s) | |
53 |
|
53 | |||
|
54 | def shouldprint(ui): | |||
|
55 | return sys.stderr.isatty() or ui.configbool('progress', 'assume-tty') | |||
|
56 | ||||
54 | class progbar(object): |
|
57 | class progbar(object): | |
55 | def __init__(self, ui): |
|
58 | def __init__(self, ui): | |
56 | self.ui = ui |
|
59 | self.ui = ui | |
@@ -69,6 +72,8 b' class progbar(object):' | |||||
69 | default=['topic', 'bar', 'number']) |
|
72 | default=['topic', 'bar', 'number']) | |
70 |
|
73 | |||
71 | def show(self, topic, pos, item, unit, total): |
|
74 | def show(self, topic, pos, item, unit, total): | |
|
75 | if not shouldprint(self.ui): | |||
|
76 | return | |||
72 | termwidth = self.width() |
|
77 | termwidth = self.width() | |
73 | self.printed = True |
|
78 | self.printed = True | |
74 | head = '' |
|
79 | head = '' | |
@@ -137,9 +142,13 b' class progbar(object):' | |||||
137 | sys.stderr.flush() |
|
142 | sys.stderr.flush() | |
138 |
|
143 | |||
139 | def clear(self): |
|
144 | def clear(self): | |
|
145 | if not shouldprint(self.ui): | |||
|
146 | return | |||
140 | sys.stderr.write('\r%s\r' % (' ' * self.width())) |
|
147 | sys.stderr.write('\r%s\r' % (' ' * self.width())) | |
141 |
|
148 | |||
142 | def complete(self): |
|
149 | def complete(self): | |
|
150 | if not shouldprint(self.ui): | |||
|
151 | return | |||
143 | if self.ui.configbool('progress', 'clear-complete', default=True): |
|
152 | if self.ui.configbool('progress', 'clear-complete', default=True): | |
144 | self.clear() |
|
153 | self.clear() | |
145 | else: |
|
154 | else: | |
@@ -177,8 +186,7 b' def uisetup(ui):' | |||||
177 | # setconfig('progress', 'disable', 'True') to disable this extension |
|
186 | # setconfig('progress', 'disable', 'True') to disable this extension | |
178 | if ui.configbool('progress', 'disable'): |
|
187 | if ui.configbool('progress', 'disable'): | |
179 | return |
|
188 | return | |
180 | if ((sys.stderr.isatty() or ui.configbool('progress', 'assume-tty')) |
|
189 | if shouldprint(ui) and not ui.debugflag and not ui.quiet: | |
181 | and not ui.debugflag and not ui.quiet): |
|
|||
182 | # we instantiate one globally shared progress bar to avoid |
|
190 | # we instantiate one globally shared progress bar to avoid | |
183 | # competing progress bars when multiple UI objects get created |
|
191 | # competing progress bars when multiple UI objects get created | |
184 | global sharedprog |
|
192 | global sharedprog |
General Comments 0
You need to be logged in to leave comments.
Login now