Rev 2612: Don't use Dots progress indicator in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Jul 13 02:26:37 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2612
revision-id: pqm at pqm.ubuntu.com-20070713012635-04mqh3w41pjxl5mg
parent: pqm at pqm.ubuntu.com-20070713004642-1kada21zx2lkwqyc
parent: mbp at sourcefrog.net-20070712230951-u8vscn58t8fwtfuw
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2007-07-13 02:26:35 +0100
message:
  Don't use Dots progress indicator
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/progress.py             progress.py-20050610070202-df9faaab791964c0
  bzrlib/tests/test_progress.py  test_progress.py-20060308160359-978c397bc79b7fda
    ------------------------------------------------------------
    revno: 2599.1.2
    merged: mbp at sourcefrog.net-20070712230951-u8vscn58t8fwtfuw
    parent: mbp at sourcefrog.net-20070711064730-pwnhisgp2caf7nar
    parent: pqm at pqm.ubuntu.com-20070712133554-r8me4pz4j68p2ytf
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: progress
    timestamp: Fri 2007-07-13 09:09:51 +1000
    message:
      merge trunk
    ------------------------------------------------------------
    revno: 2599.1.1
    merged: mbp at sourcefrog.net-20070711064730-pwnhisgp2caf7nar
    parent: pqm at pqm.ubuntu.com-20070711041950-ci5yz9nyhbcdmuqv
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: progress
    timestamp: Wed 2007-07-11 16:47:30 +1000
    message:
      Don't show dots progress indicatiors in noninteractive mode
=== modified file 'NEWS'
--- a/NEWS	2007-07-12 13:35:54 +0000
+++ b/NEWS	2007-07-12 23:09:51 +0000
@@ -8,6 +8,9 @@
 
   IMPROVEMENTS:
 
+    * Don't show "dots" progress indicators when run non-interactively, such
+      as from cron.  (Martin Pool)
+
     * ``info`` now formats locations more nicely and lists "submit" and
       "public" branches (Aaron Bentley)
 

=== modified file 'bzrlib/progress.py'
--- a/bzrlib/progress.py	2006-11-03 23:29:49 +0000
+++ b/bzrlib/progress.py	2007-07-11 06:47:30 +0000
@@ -50,6 +50,11 @@
 
 
 def _supports_progress(f):
+    """Detect if we can use pretty progress bars on the output stream f.
+
+    If this returns true we expect that a human may be looking at that 
+    output, and that we can repaint a line to update it.
+    """
     isatty = getattr(f, 'isatty', None)
     if isatty is None:
         return False
@@ -74,7 +79,7 @@
         if _supports_progress(to_file):
             return TTYProgressBar(to_file=to_file, **kwargs)
         else:
-            return DotsProgressBar(to_file=to_file, **kwargs)
+            return DummyProgress(to_file=to_file, **kwargs)
     else:
         # Minor sanitation to prevent spurious errors
         requested_bar_type = requested_bar_type.lower().strip()

=== modified file 'bzrlib/tests/test_progress.py'
--- a/bzrlib/tests/test_progress.py	2006-10-11 23:08:27 +0000
+++ b/bzrlib/tests/test_progress.py	2007-07-11 06:47:30 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 Canonical Ltd
+# Copyright (C) 2006, 2007 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -19,7 +19,8 @@
 
 from bzrlib import errors
 from bzrlib.progress import (
-        DummyProgress, ChildProgress,
+        DummyProgress,
+        ChildProgress,
         TTYProgressBar,
         DotsProgressBar,
         ProgressBarStack,
@@ -243,19 +244,27 @@
                          '\r                   \r',
                          out.getvalue())
 
+    def test_noninteractive_progress(self):
+        out = _NonTTYStringIO()
+        pb = self.get_nested(out, 'xterm')
+        self.assertIsInstance(pb, DummyProgress)
+        try:
+            pb.update('foo', 1, 2)
+            pb.update('bar', 2, 2)
+        finally:
+            pb.finished()
+        self.assertEqual('', out.getvalue())
+
     def test_dots_progress(self):
-        # Make sure the ProgressBarStack thinks it is
-        # not writing out to a terminal, and thus uses a 
-        # DotsProgressBar
+        # make sure we get the right progress bar when not on a terminal
         out = _NonTTYStringIO()
-        pb = self.get_nested(out, 'xterm')
+        pb = self.get_nested(out, 'xterm', 'dots')
         self.assertIsInstance(pb, DotsProgressBar)
         try:
             pb.update('foo', 1, 2)
             pb.update('bar', 2, 2)
         finally:
             pb.finished()
-
         self.assertEqual('foo: .'
                          '\nbar: .'
                          '\n',
@@ -267,16 +276,14 @@
         out = cStringIO.StringIO()
         pb = self.get_nested(out, 'xterm')
         pb.finished()
-        self.assertIsInstance(pb, DotsProgressBar)
+        self.assertIsInstance(pb, DummyProgress)
 
     def test_dumb_progress(self):
-        # Make sure the ProgressBarStack thinks it is writing out to a 
-        # terminal, but it is the emacs 'dumb' terminal, so it uses
-        # Dots
+        # using a terminal that can't do cursor movement
         out = _TTYStringIO()
         pb = self.get_nested(out, 'dumb')
         pb.finished()
-        self.assertIsInstance(pb, DotsProgressBar)
+        self.assertIsInstance(pb, DummyProgress)
 
     def test_progress_env_tty(self):
         # The environ variable BZR_PROGRESS_BAR controls what type of
@@ -290,13 +297,6 @@
         # Even though we are not a tty, the env_var will override
         self.assertIsInstance(pb, TTYProgressBar)
 
-    def test_progress_env_dots(self):
-        # Even though we are in a tty, the env_var will override
-        out = _TTYStringIO()
-        pb = self.get_nested(out, 'xterm', 'dots')
-        pb.finished()
-        self.assertIsInstance(pb, DotsProgressBar)
-
     def test_progress_env_none(self):
         # Even though we are in a valid tty, no progress
         out = _TTYStringIO()




More information about the bazaar-commits mailing list