comparison mercurial/ui.py @ 43265:82879e06c926

ui: option to preserve the progress bar Some interface like the fast-import format of git are meant for pipe processing. It can be still desirable to have progress bars in this case, but clearing the bar after each output operation is not desirable. Differential Revision: https://phab.mercurial-scm.org/D6843
author Joerg Sonnenberger <joerg@bec.de>
date Thu, 12 Sep 2019 03:40:54 +0200
parents 57efd5bd2ca2
children aaa046919043
comparison
equal deleted inserted replaced
43264:a4da1c3b82ab 43265:82879e06c926
1070 The color used is controlled by an optional keyword argument, "label". 1070 The color used is controlled by an optional keyword argument, "label".
1071 This should be a string containing label names separated by space. 1071 This should be a string containing label names separated by space.
1072 Label names take the form of "topic.type". For example, ui.debug() 1072 Label names take the form of "topic.type". For example, ui.debug()
1073 issues a label of "ui.debug". 1073 issues a label of "ui.debug".
1074 1074
1075 Progress reports via stderr are normally cleared before writing as
1076 stdout and stderr go to the same terminal. This can be skipped with
1077 the optional keyword argument "keepprogressbar". The progress bar
1078 will continue to occupy a partial line on stderr in that case.
1079 This functionality is intended when Mercurial acts as data source
1080 in a pipe.
1081
1075 When labeling output for a specific command, a label of 1082 When labeling output for a specific command, a label of
1076 "cmdname.type" is recommended. For example, status issues 1083 "cmdname.type" is recommended. For example, status issues
1077 a label of "status.modified" for modified files. 1084 a label of "status.modified" for modified files.
1078 ''' 1085 '''
1079 dest = self._fout 1086 dest = self._fout
1085 self._buffers[-1].extend(self.label(a, label) for a in args) 1092 self._buffers[-1].extend(self.label(a, label) for a in args)
1086 else: 1093 else:
1087 self._buffers[-1].extend(args) 1094 self._buffers[-1].extend(args)
1088 return 1095 return
1089 1096
1090 # inliend _writenobuf() for speed 1097 # inlined _writenobuf() for speed
1091 self._progclear() 1098 if not opts.get(r'keepprogressbar', False):
1099 self._progclear()
1092 msg = b''.join(args) 1100 msg = b''.join(args)
1093 1101
1094 # opencode timeblockedsection because this is a critical path 1102 # opencode timeblockedsection because this is a critical path
1095 starttime = util.timer() 1103 starttime = util.timer()
1096 try: 1104 try:
1124 else: 1132 else:
1125 self._writenobuf(dest, *args, **opts) 1133 self._writenobuf(dest, *args, **opts)
1126 1134
1127 def _writenobuf(self, dest, *args, **opts): 1135 def _writenobuf(self, dest, *args, **opts):
1128 # update write() as well if you touch this code 1136 # update write() as well if you touch this code
1129 self._progclear() 1137 if not opts.get(r'keepprogressbar', False):
1138 self._progclear()
1130 msg = b''.join(args) 1139 msg = b''.join(args)
1131 1140
1132 # opencode timeblockedsection because this is a critical path 1141 # opencode timeblockedsection because this is a critical path
1133 starttime = util.timer() 1142 starttime = util.timer()
1134 try: 1143 try: