Suggested fix lp:#213718 (bazaar pager)

Richard Wilbur richard.wilbur at gmail.com
Mon Apr 13 00:44:22 UTC 2015


On Sun, Apr 12, 2015 at 2:04 PM, Daniel Vedder <d.vedder at web.de> wrote:
> OK, I added the BZR_PAGER variable and figured out how to auto-adjust
> the pager-threshold. Along the way I discovered an undocumented variable
> BZR_COLUMNS from osutil.py, so I added a documentation entry for it.

Nice!  Thank you for the serendipitous documentation entry.

> @Richard: I couldn't exactly change my previous code to match your
> suggestions, because Python doesn't seem to support variable assignment
> inside a test condition:

You're right.  That's why I mentioned I hadn't tested the code.  I was
thinking in a different language at the time.  Sorry about that.

The implementation in the latest patch looks like it will overlook the
first '\n' if it is the first character of text, and otherwise it will
count one more than the number of lines actually encountered.  Here's
a new suggestion for that section:

+            number_of_lines = 0
+            start = text.find("\n")
+            while start > -1:
+                number_of_lines = number_of_lines + 1
+                if number_of_lines > self.pager_cutoff:
+                    return True
+                start = text.find("\n", start+1)
+            return False

Sincerely,
Richard



More information about the bazaar mailing list