/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/ui/__init__.py

  • Committer: Martin Pool
  • Date: 2010-02-09 19:04:02 UTC
  • mfrom: (5010 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5019.
  • Revision ID: mbp@canonical.com-20100209190402-2xbzrchmb4dfi2j7
Resolve conflicts with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
109
109
 
110
110
    def __init__(self):
111
111
        self._task_stack = []
 
112
        self._quiet = False
 
113
 
 
114
    def be_quiet(self, state):
 
115
        """Tell the UI to be more quiet, or not.
 
116
 
 
117
        Typically this suppresses progress bars; the application may also look
 
118
        at ui_factory.is_quiet().
 
119
        """
 
120
        self._quiet = state
112
121
 
113
122
    def get_password(self, prompt='', **kwargs):
114
123
        """Prompt the user for a password.
125
134
        """
126
135
        raise NotImplementedError(self.get_password)
127
136
 
 
137
    def is_quiet(self):
 
138
        return self._quiet
 
139
 
128
140
    def make_output_stream(self, encoding=None, encoding_type=None):
129
141
        """Get a stream for sending out bulk text data.
130
142
 
263
275
        """Show an error message (not an exception) to the user.
264
276
        
265
277
        The message should not have an error prefix or trailing newline.  That
266
 
        will be added by the factory if appropriate. 
 
278
        will be added by the factory if appropriate.
267
279
        """
268
280
        raise NotImplementedError(self.show_error)
269
281
 
275
287
        """Show a warning to the user."""
276
288
        raise NotImplementedError(self.show_warning)
277
289
 
 
290
    def warn_cross_format_fetch(self, from_format, to_format):
 
291
        """Warn about a potentially slow cross-format transfer"""
 
292
        # See <https://launchpad.net/bugs/456077> asking for a warning here
 
293
        trace.warning("Doing on-the-fly conversion from %s to %s.\n"
 
294
            "This may take some time. Upgrade the repositories to the "
 
295
            "same format for better performance.\n" %
 
296
            (from_format, to_format))
278
297
 
279
298
 
280
299
class SilentUIFactory(UIFactory):
296
315
    def get_username(self, prompt, **kwargs):
297
316
        return None
298
317
 
 
318
    def _make_output_stream_explicit(self, encoding, encoding_type):
 
319
        return NullOutputStream(encoding)
 
320
 
299
321
    def show_error(self, msg):
300
322
        pass
301
323
 
361
383
 
362
384
    def log_transport_activity(self, display=False):
363
385
        pass
 
386
 
 
387
 
 
388
class NullOutputStream(object):
 
389
    """Acts like a file, but discard all output."""
 
390
 
 
391
    def __init__(self, encoding):
 
392
        self.encoding = encoding
 
393
 
 
394
    def write(self, data):
 
395
        pass
 
396
 
 
397
    def writelines(self, data):
 
398
        pass
 
399
 
 
400
    def close(self):
 
401
        pass