Merge lp:~nmb/bzr/675652-bzr-columns-0 into lp:bzr

Proposed by Neil Martinsen-Burrell
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 5598
Proposed branch: lp:~nmb/bzr/675652-bzr-columns-0
Merge into: lp:bzr
Diff against target: 65 lines (+19/-2)
4 files modified
bzrlib/osutils.py (+8/-2)
bzrlib/tests/blackbox/test_help.py (+4/-0)
bzrlib/tests/test_osutils.py (+4/-0)
doc/en/release-notes/bzr-2.3.txt (+3/-0)
To merge this branch: bzr merge lp:~nmb/bzr/675652-bzr-columns-0
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Martin Pool Approve
Review via email: mp+45660@code.launchpad.net

Commit message

Accept 0 to mean no limit for BZR_COLUMNS

Description of the change

This change fixes bug 675652 by allowing the environment variable BZR_COLUMNS to be set to 0 to indicate no preference for terminal width.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

That makes sense to me. I guess you also checked it does fix the
issue interactively?

  vote approve

Martin

review: Approve
Revision history for this message
Neil Martinsen-Burrell (nmb) wrote :

On Jan 10, 2011, at 0:01, Martin Pool <email address hidden> wrote:

> Review: Approve
> That makes sense to me. I guess you also checked it does fix the
> issue interactively?

It works correctly interactively, that is, it fixes the traceback in the bug and for log and stat it provides unlimited line lengths. However, 'bzr help' uses a default width of 80 characters when osutils.terminal_width() returns None, which doesn't seem to be what the bug reporter wants. However, I think that is a separate UI bug from fixing the traceback.

Revision history for this message
Vincent Ladeuil (vila) wrote :

IIRC the help 80 default width is not under our direct control anyway and will probably require a more invasive change.

review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/osutils.py'
2--- bzrlib/osutils.py 2010-11-06 02:32:43 +0000
3+++ bzrlib/osutils.py 2011-01-10 05:34:04 +0000
4@@ -1461,10 +1461,16 @@
5 # a similar effect.
6
7 # If BZR_COLUMNS is set, take it, user is always right
8+ # Except if they specified 0 in which case, impose no limit here
9 try:
10- return int(os.environ['BZR_COLUMNS'])
11+ width = int(os.environ['BZR_COLUMNS'])
12 except (KeyError, ValueError):
13- pass
14+ width = None
15+ if width is not None:
16+ if width > 0:
17+ return width
18+ else:
19+ return None
20
21 isatty = getattr(sys.stdout, 'isatty', None)
22 if isatty is None or not isatty():
23
24=== modified file 'bzrlib/tests/blackbox/test_help.py'
25--- bzrlib/tests/blackbox/test_help.py 2010-08-29 14:32:45 +0000
26+++ bzrlib/tests/blackbox/test_help.py 2011-01-10 05:34:04 +0000
27@@ -104,6 +104,10 @@
28 self.assertEquals(dash_help, qmark_long)
29 self.assertEquals(dash_help, qmark_cmds)
30
31+ def test_help_width_zero(self):
32+ self.overrideEnv('BZR_COLUMNS', '0')
33+ self.run_bzr('help commands')
34+
35 def test_hidden(self):
36 help_commands = self.run_bzr('help commands')[0]
37 help_hidden = self.run_bzr('help hidden-commands')[0]
38
39=== modified file 'bzrlib/tests/test_osutils.py'
40--- bzrlib/tests/test_osutils.py 2010-12-16 15:29:10 +0000
41+++ bzrlib/tests/test_osutils.py 2011-01-10 05:34:04 +0000
42@@ -1988,6 +1988,10 @@
43 self.overrideEnv('BZR_COLUMNS', '12')
44 self.assertEqual(12, osutils.terminal_width())
45
46+ def test_BZR_COLUMNS_0_no_limit(self):
47+ self.overrideEnv('BZR_COLUMNS', '0')
48+ self.assertEqual(None, osutils.terminal_width())
49+
50 def test_falls_back_to_COLUMNS(self):
51 self.overrideEnv('BZR_COLUMNS', None)
52 self.assertNotEqual('42', os.environ['COLUMNS'])
53
54=== modified file 'doc/en/release-notes/bzr-2.3.txt'
55--- doc/en/release-notes/bzr-2.3.txt 2010-12-24 16:30:36 +0000
56+++ doc/en/release-notes/bzr-2.3.txt 2011-01-10 05:34:04 +0000
57@@ -55,6 +55,9 @@
58 .. Fixes for situations where bzr would previously crash or give incorrect
59 or undesirable results.
60
61+* The BZR_COLUMNS environment variable can be set to 0 to indicate no
62+ limitation on the width of the terminal. (Neil Martinsen-Burrell, #675652)
63+
64 Documentation
65 *************
66