Mercurial > public > mercurial-scm > hg-stable
diff mercurial/ui.py @ 25499:0fa964d6fd48
progress: move all logic altering the ui object logic in mercurial.ui
The ui object can take care of its progress object logic by itself.
test-subrepo-recursion is modified because it is a bit sensitive to the "no
progress bar" default. It will become unnecessary in the next step when
progress will be on by default in core.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sun, 07 Jun 2015 17:50:56 -0700 |
parents | 7a5335ed7e1a |
children | 09e2cb2a00d7 |
line wrap: on
line diff
--- a/mercurial/ui.py Sun Jun 07 17:26:34 2015 -0700 +++ b/mercurial/ui.py Sun Jun 07 17:50:56 2015 -0700 @@ -584,6 +584,7 @@ "cmdname.type" is recommended. For example, status issues a label of "status.modified" for modified files. ''' + self._progclear() if self._buffers: self._buffers[-1].extend([str(a) for a in args]) else: @@ -591,6 +592,7 @@ self.fout.write(str(a)) def write_err(self, *args, **opts): + self._progclear() try: if self._bufferstates and self._bufferstates[-1][0]: return self.write(*args, **opts) @@ -886,6 +888,22 @@ os.environ.get("VISUAL") or os.environ.get("EDITOR", editor)) + @util.propertycache + def _progbar(self): + """setup the progbar singleton to the ui object""" + if (self.quiet or self.debugflag + or self.configbool('progress', 'disable', True) + or not progress.shouldprint(self)): + return None + return getprogbar(self) + + def _progclear(self): + """clear progress bar output if any. use it before any output""" + if '_progbar' not in vars(self): # nothing loadef yet + return + if self._progbar is not None and self._progbar.printed: + self._progbar.clear() + def progress(self, topic, pos, item="", unit="", total=None): '''show a progress message @@ -902,7 +920,9 @@ All topics should be marked closed by setting pos to None at termination. ''' - + if self._progbar is not None: + self._progbar.progress(topic, pos, item=item, unit=unit, + total=total) if pos is None or not self.configbool('progress', 'debug'): return