Rev 4756: Fixed as per poolie's review. in file:///home/vila/src/bzr/bugs/353370-notty-no-term-width/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Fri Dec 4 10:09:11 GMT 2009
At file:///home/vila/src/bzr/bugs/353370-notty-no-term-width/
------------------------------------------------------------
revno: 4756
revision-id: v.ladeuil+lp at free.fr-20091204100911-8pyp5gysqrp2deh5
parent: v.ladeuil+lp at free.fr-20091202162142-9iocf4fq8dy5q28k
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 353370-notty-no-term-width
timestamp: Fri 2009-12-04 11:09:11 +0100
message:
Fixed as per poolie's review.
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2009-12-02 16:21:42 +0000
+++ b/NEWS 2009-12-04 10:09:11 +0000
@@ -29,7 +29,8 @@
* The ``BZR_COLUMNS`` envrionment variable can be set to force bzr to
respect a given terminal width. This can be useful when output is
redirected or in obscure cases where the default value is not
- appropriate.
+ appropriate. Pagers can use it to get a better control of the line
+ lengths.
(Vincent Ladeuil)
Bug Fixes
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2009-12-02 16:21:42 +0000
+++ b/bzrlib/osutils.py 2009-12-04 10:09:11 +0000
@@ -1350,12 +1350,6 @@
except (KeyError, ValueError):
pass
- # If COLUMNS is set, take it, the terminal knows better
- try:
- return int(os.environ['COLUMNS'])
- except (KeyError, ValueError):
- pass
-
isatty = getattr(sys.stdout, 'isatty', None)
if isatty is None or not isatty():
# Don't guess, setting BZR_COLUMNS is the recommended way to override.
@@ -1370,9 +1364,14 @@
x = fcntl.ioctl(1, termios.TIOCGWINSZ, s)
width = struct.unpack('HHHH', x)[1]
except (IOError, AttributeError):
- return None
+ # If COLUMNS is set, take it
+ try:
+ return int(os.environ['COLUMNS'])
+ except (KeyError, ValueError):
+ return None
if width <= 0:
+ # Consider invalid values as meaning no width
return None
return width
=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py 2009-12-02 16:21:42 +0000
+++ b/bzrlib/tests/test_osutils.py 2009-12-04 10:09:11 +0000
@@ -1936,11 +1936,6 @@
os.environ['BZR_COLUMNS'] = '12'
self.assertEquals(12, osutils.terminal_width())
- def test_falls_back_to_COLUMNS(self):
- del os.environ['BZR_COLUMNS']
- os.environ['COLUMNS'] = '42'
- self.assertEquals(42, osutils.terminal_width())
-
def test_tty_default_without_columns(self):
del os.environ['BZR_COLUMNS']
del os.environ['COLUMNS']
More information about the bazaar-commits
mailing list