##// END OF EJS Templates
progress: extract stubs to restart ferr.flush() and .write() on EINTR
Yuya Nishihara -
r32048:c3ef33fd default
parent child Browse files
Show More
@@ -157,14 +157,14 b' class progbar(object):'
157 out = spacejoin(head, prog, tail)
157 out = spacejoin(head, prog, tail)
158 else:
158 else:
159 out = spacejoin(head, tail)
159 out = spacejoin(head, tail)
160 self.ui.ferr.write('\r' + encoding.trim(out, termwidth))
160 self._writeerr('\r' + encoding.trim(out, termwidth))
161 self.lasttopic = topic
161 self.lasttopic = topic
162 self.ui.ferr.flush()
162 self._flusherr()
163
163
164 def clear(self):
164 def clear(self):
165 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):
166 return
166 return
167 self.ui.ferr.write('\r%s\r' % (' ' * self.width()))
167 self._writeerr('\r%s\r' % (' ' * self.width()))
168 if self.printed:
168 if self.printed:
169 # force immediate re-paint of progress bar
169 # force immediate re-paint of progress bar
170 self.lastprint = 0
170 self.lastprint = 0
@@ -175,9 +175,15 b' class progbar(object):'
175 if self.ui.configbool('progress', 'clear-complete', default=True):
175 if self.ui.configbool('progress', 'clear-complete', default=True):
176 self.clear()
176 self.clear()
177 else:
177 else:
178 self.ui.ferr.write('\n')
178 self._writeerr('\n')
179 self._flusherr()
180
181 def _flusherr(self):
179 self.ui.ferr.flush()
182 self.ui.ferr.flush()
180
183
184 def _writeerr(self, msg):
185 self.ui.ferr.write(msg)
186
181 def width(self):
187 def width(self):
182 tw = self.ui.termwidth()
188 tw = self.ui.termwidth()
183 return min(int(self.ui.config('progress', 'width', default=tw)), tw)
189 return min(int(self.ui.config('progress', 'width', default=tw)), tw)
General Comments 0
You need to be logged in to leave comments. Login now