~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

(vila) Add a config option for the progress bar type. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
import warnings
32
32
 
33
33
from bzrlib import (
 
34
    config,
34
35
    debug,
35
36
    progress,
36
37
    osutils,
155
156
            return index
156
157
 
157
158
 
 
159
opt_progress_bar = config.Option(
 
160
    'progress_bar', help='Progress bar type.',
 
161
    default_from_env=['BZR_PROGRESS_BAR'], default=None,
 
162
    invalid='error')
 
163
 
 
164
 
158
165
class TextUIFactory(UIFactory):
159
 
    """A UI factory for Text user interefaces."""
 
166
    """A UI factory for Text user interfaces."""
160
167
 
161
168
    def __init__(self,
162
169
                 stdin=None,
279
286
        # do that.  otherwise, guess based on $TERM and tty presence.
280
287
        if self.is_quiet():
281
288
            return NullProgressView()
282
 
        elif os.environ.get('BZR_PROGRESS_BAR') == 'text':
283
 
            return TextProgressView(self.stderr)
284
 
        elif os.environ.get('BZR_PROGRESS_BAR') == 'none':
285
 
            return NullProgressView()
286
 
        elif progress._supports_progress(self.stderr):
287
 
            return TextProgressView(self.stderr)
288
 
        else:
289
 
            return NullProgressView()
 
289
        pb_type = config.GlobalStack().get('progress_bar')
 
290
        if pb_type == 'none': # Explicit requirement
 
291
            return NullProgressView()
 
292
        if (pb_type == 'text' # Explicit requirement
 
293
            or progress._supports_progress(self.stderr)): # Guess
 
294
            return TextProgressView(self.stderr)
 
295
        # No explicit requirement and no successful guess
 
296
        return NullProgressView()
290
297
 
291
298
    def _make_output_stream_explicit(self, encoding, encoding_type):
292
299
        if encoding_type == 'exact':