[PATCH V3] util.termwidth: never return 0 for terminal width

Jason Harris jason.f.harris at gmail.com
Mon May 2 14:36:34 CDT 2011


# HG changeset patch
# User jfh <jason at jasonfharris.com>
# Date 1303087372 -7200
# Node ID 14d1b163e9f0f6f45a58653a35102033e0303660
# Parent  e83ced8b6464ff8f4c6cd9e4b780ba4b5d6208e0
util.termwidth: never return 0 for terminal width

Catch a case where the termwidth was being reported as 0 when I was connecting
with TLMTask instead of NSTask in OSX. This caused the progress extension to
print no progress. The termwidth should never return 0 so in case we would
return 0, simply fall back to the default termwidth below which is 80.

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -316,7 +316,9 @@
                 if not os.isatty(fd):
                     continue
                 arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8)
-                return array.array('h', arri)[1]
+                width = array.array('h', arri)[1]
+                if width > 0:
+                    return width
             except ValueError:
                 pass
             except IOError, e:


More information about the Mercurial-devel mailing list