util.termwidth: never return 0 for terminal width
authorjfh <jason@jasonfharris.com>
Mon, 18 Apr 2011 02:42:52 +0200
changeset 14165 78bdfc756908
parent 14164 cb98fed52495
child 14166 9cbff8a39a2a
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.
mercurial/posix.py
--- a/mercurial/posix.py	Mon May 02 19:21:30 2011 +0200
+++ b/mercurial/posix.py	Mon Apr 18 02:42:52 2011 +0200
@@ -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: