Rev 4764: (joke, vila) terminal_width is now very large for non-tty in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Oct 22 10:48:26 BST 2009


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

------------------------------------------------------------
revno: 4764 [merge]
revision-id: pqm at pqm.ubuntu.com-20091022094825-p8f7l834runsr2op
parent: pqm at pqm.ubuntu.com-20091022074533-1ll6d040i4ofk77b
parent: v.ladeuil+lp at free.fr-20091022084942-r6c1s2io9x8xjs8m
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-10-22 10:48:25 +0100
message:
  (joke, vila) terminal_width is now very large for non-tty
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
=== modified file 'NEWS'
--- a/NEWS	2009-10-22 01:07:25 +0000
+++ b/NEWS	2009-10-22 08:49:42 +0000
@@ -25,6 +25,10 @@
 * ``bzr+http`` servers no longer give spurious jail break errors when
   serving branches inside a shared repository.  (Andrew Bennetts, #348308)
 
+* ``osutils.terminal_width()`` will now return a very large value
+  to avoid truuncated lines when using pagers (for example).
+  (Joke de Buhr, Vincent Ladeuil, #353370)
+
 * TreeTransform.adjust_path updates the limbo paths of descendants of adjusted
   files.  (Aaron Bentley)
 

=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2009-10-15 04:01:26 +0000
+++ b/bzrlib/osutils.py	2009-10-22 08:40:35 +0000
@@ -1296,6 +1296,14 @@
 
 def terminal_width():
     """Return estimated terminal width."""
+    if getattr(sys.stdout, 'isatty', None) is None:
+        # If it's not a tty, the width makes no sense. We just use a value bug
+        # enough to avoid truncations. When the output is redirected, the
+        # pagers can then handle that themselves. A cleaner implementation
+        # would be to fix the callers to not try to format at all in these
+        # circumstances.
+        return 65536
+
     if sys.platform == 'win32':
         return win32utils.get_console_size()[0]
     width = 0




More information about the bazaar-commits mailing list