/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/text.py

  • Committer: Marius Kruger
  • Date: 2009-10-31 23:07:35 UTC
  • mfrom: (4780 +trunk)
  • mto: (4867.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4868.
  • Revision ID: marius.kruger@enerweb.co.za-20091031230735-4hyr0u14nci0xu7b
merge with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from bzrlib.lazy_import import lazy_import
28
28
lazy_import(globals(), """
29
29
from bzrlib import (
 
30
    debug,
30
31
    progress,
31
32
    osutils,
32
33
    symbol_versioning,
48
49
                 stdout=None,
49
50
                 stderr=None):
50
51
        """Create a TextUIFactory.
51
 
 
52
 
        :param bar_type: The type of progress bar to create. It defaults to
53
 
                         letting the bzrlib.progress.ProgressBar factory auto
54
 
                         select.   Deprecated.
55
52
        """
56
53
        super(TextUIFactory, self).__init__()
57
54
        # TODO: there's no good reason not to pass all three streams, maybe we
176
173
        self._progress_view.show_transport_activity(transport,
177
174
            direction, byte_count)
178
175
 
 
176
    def show_error(self, msg):
 
177
        self.clear_term()
 
178
        self.stderr.write("bzr: error: %s\n" % msg)
 
179
 
 
180
    def show_message(self, msg):
 
181
        self.note(msg)
 
182
 
 
183
    def show_warning(self, msg):
 
184
        self.clear_term()
 
185
        self.stderr.write("bzr: warning: %s\n" % msg)
 
186
 
179
187
    def _progress_updated(self, task):
180
188
        """A task has been updated and wants to be displayed.
181
189
        """
222
230
        self._last_task = None
223
231
        self._total_byte_count = 0
224
232
        self._bytes_since_update = 0
 
233
        self._fraction = 0
225
234
 
226
235
    def _show_line(self, s):
 
236
        # sys.stderr.write("progress %r\n" % s)
227
237
        n = self._width - 1
228
238
        self._term_file.write('\r%-*.*s\r' % (n, n, s))
229
239
 
245
255
            cols = 20
246
256
            if self._last_task is None:
247
257
                completion_fraction = 0
 
258
                self._fraction = 0
248
259
            else:
249
260
                completion_fraction = \
250
261
                    self._last_task._overall_completion_fraction() or 0
 
262
            if (completion_fraction < self._fraction and 'progress' in
 
263
                debug.debug_flags):
 
264
                import pdb;pdb.set_trace()
 
265
            self._fraction = completion_fraction
251
266
            markers = int(round(float(cols) * completion_fraction)) - 1
252
267
            bar_str = '[' + ('#' * markers + spin_str).ljust(cols) + '] '
253
268
            return bar_str
283
298
            task_msg = self._format_task(self._last_task)
284
299
        else:
285
300
            task_msg = ''
286
 
        trans = self._last_transport_msg
287
 
        if trans:
288
 
            trans += ' | '
 
301
        if self._last_task and not self._last_task.show_transport_activity:
 
302
            trans = ''
 
303
        else:
 
304
            trans = self._last_transport_msg
 
305
            if trans:
 
306
                trans += ' | '
289
307
        return (bar_string + trans + task_msg)
290
308
 
291
309
    def _repaint(self):
302
320
        must_update = task is not self._last_task
303
321
        self._last_task = task
304
322
        now = time.time()
305
 
        if (not must_update) and (now < self._last_repaint + 0.1):
 
323
        if (not must_update) and (now < self._last_repaint + task.update_latency):
306
324
            return
307
325
        if now > self._transport_update_time + 10:
308
326
            # no recent activity; expire it
330
348
        self._total_byte_count += byte_count
331
349
        self._bytes_since_update += byte_count
332
350
        now = time.time()
 
351
        if self._total_byte_count < 2000:
 
352
            # a little resistance at first, so it doesn't stay stuck at 0
 
353
            # while connecting...
 
354
            return
333
355
        if self._transport_update_time is None:
334
356
            self._transport_update_time = now
335
357
        elif now >= (self._transport_update_time + 0.5):