582 |
582 |
583 When labeling output for a specific command, a label of |
583 When labeling output for a specific command, a label of |
584 "cmdname.type" is recommended. For example, status issues |
584 "cmdname.type" is recommended. For example, status issues |
585 a label of "status.modified" for modified files. |
585 a label of "status.modified" for modified files. |
586 ''' |
586 ''' |
|
587 self._progclear() |
587 if self._buffers: |
588 if self._buffers: |
588 self._buffers[-1].extend([str(a) for a in args]) |
589 self._buffers[-1].extend([str(a) for a in args]) |
589 else: |
590 else: |
590 for a in args: |
591 for a in args: |
591 self.fout.write(str(a)) |
592 self.fout.write(str(a)) |
592 |
593 |
593 def write_err(self, *args, **opts): |
594 def write_err(self, *args, **opts): |
|
595 self._progclear() |
594 try: |
596 try: |
595 if self._bufferstates and self._bufferstates[-1][0]: |
597 if self._bufferstates and self._bufferstates[-1][0]: |
596 return self.write(*args, **opts) |
598 return self.write(*args, **opts) |
597 if not getattr(self.fout, 'closed', False): |
599 if not getattr(self.fout, 'closed', False): |
598 self.fout.flush() |
600 self.fout.flush() |
884 return (os.environ.get("HGEDITOR") or |
886 return (os.environ.get("HGEDITOR") or |
885 self.config("ui", "editor") or |
887 self.config("ui", "editor") or |
886 os.environ.get("VISUAL") or |
888 os.environ.get("VISUAL") or |
887 os.environ.get("EDITOR", editor)) |
889 os.environ.get("EDITOR", editor)) |
888 |
890 |
|
891 @util.propertycache |
|
892 def _progbar(self): |
|
893 """setup the progbar singleton to the ui object""" |
|
894 if (self.quiet or self.debugflag |
|
895 or self.configbool('progress', 'disable', True) |
|
896 or not progress.shouldprint(self)): |
|
897 return None |
|
898 return getprogbar(self) |
|
899 |
|
900 def _progclear(self): |
|
901 """clear progress bar output if any. use it before any output""" |
|
902 if '_progbar' not in vars(self): # nothing loadef yet |
|
903 return |
|
904 if self._progbar is not None and self._progbar.printed: |
|
905 self._progbar.clear() |
|
906 |
889 def progress(self, topic, pos, item="", unit="", total=None): |
907 def progress(self, topic, pos, item="", unit="", total=None): |
890 '''show a progress message |
908 '''show a progress message |
891 |
909 |
892 With stock hg, this is simply a debug message that is hidden |
910 With stock hg, this is simply a debug message that is hidden |
893 by default, but with extensions or GUI tools it may be |
911 by default, but with extensions or GUI tools it may be |
900 Multiple nested topics may be active at a time. |
918 Multiple nested topics may be active at a time. |
901 |
919 |
902 All topics should be marked closed by setting pos to None at |
920 All topics should be marked closed by setting pos to None at |
903 termination. |
921 termination. |
904 ''' |
922 ''' |
905 |
923 if self._progbar is not None: |
|
924 self._progbar.progress(topic, pos, item=item, unit=unit, |
|
925 total=total) |
906 if pos is None or not self.configbool('progress', 'debug'): |
926 if pos is None or not self.configbool('progress', 'debug'): |
907 return |
927 return |
908 |
928 |
909 if unit: |
929 if unit: |
910 unit = ' ' + unit |
930 unit = ' ' + unit |