##// END OF EJS Templates
progress: obtain stderr from ui...
Yuya Nishihara -
r30324:cb1ea3cc default
parent child Browse files
Show More
@@ -7,7 +7,6 b''
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import sys
11 import threading
10 import threading
12 import time
11 import time
13
12
@@ -19,7 +18,7 b' def spacejoin(*args):'
19
18
20 def shouldprint(ui):
19 def shouldprint(ui):
21 return not (ui.quiet or ui.plain('progress')) and (
20 return not (ui.quiet or ui.plain('progress')) and (
22 ui._isatty(sys.stderr) or ui.configbool('progress', 'assume-tty'))
21 ui._isatty(ui.ferr) or ui.configbool('progress', 'assume-tty'))
23
22
24 def fmtremaining(seconds):
23 def fmtremaining(seconds):
25 """format a number of remaining seconds in human readable way
24 """format a number of remaining seconds in human readable way
@@ -158,14 +157,14 b' class progbar(object):'
158 out = spacejoin(head, prog, tail)
157 out = spacejoin(head, prog, tail)
159 else:
158 else:
160 out = spacejoin(head, tail)
159 out = spacejoin(head, tail)
161 sys.stderr.write('\r' + encoding.trim(out, termwidth))
160 self.ui.ferr.write('\r' + encoding.trim(out, termwidth))
162 self.lasttopic = topic
161 self.lasttopic = topic
163 sys.stderr.flush()
162 self.ui.ferr.flush()
164
163
165 def clear(self):
164 def clear(self):
166 if not self.printed or not self.lastprint or not shouldprint(self.ui):
165 if not self.printed or not self.lastprint or not shouldprint(self.ui):
167 return
166 return
168 sys.stderr.write('\r%s\r' % (' ' * self.width()))
167 self.ui.ferr.write('\r%s\r' % (' ' * self.width()))
169 if self.printed:
168 if self.printed:
170 # force immediate re-paint of progress bar
169 # force immediate re-paint of progress bar
171 self.lastprint = 0
170 self.lastprint = 0
@@ -176,8 +175,8 b' class progbar(object):'
176 if self.ui.configbool('progress', 'clear-complete', default=True):
175 if self.ui.configbool('progress', 'clear-complete', default=True):
177 self.clear()
176 self.clear()
178 else:
177 else:
179 sys.stderr.write('\n')
178 self.ui.ferr.write('\n')
180 sys.stderr.flush()
179 self.ui.ferr.flush()
181
180
182 def width(self):
181 def width(self):
183 tw = self.ui.termwidth()
182 tw = self.ui.termwidth()
General Comments 0
You need to be logged in to leave comments. Login now