[PATCH] posix.py: workaround lack of TIOCGWINSZ on Irix (issue3449)

Mark Round mark at markround.com
Mon May 14 07:33:32 CDT 2012


# HG changeset patch
# User Mark Round <hg at markround.com>
# Date 1336998342 -3600
# Node ID 1c9bc6a66fc3048aecab8e46215d413957a5e715
# Parent  0a176990243c9b4753039867164cfed560806fb7
posix.py: workaround lack of TIOCGWINSZ on Irix (issue3449)

On an Irix 6.5.24 system, TIOCGWINSZ is not available. This means that
any usage of the "hg" tool that looks up the terminal size (e.g. "hg
help") will fail with an AttributeError.

A simple work-around is just to wrap this block in mercurial/posix.py
with a try/except so that it ends up using the default 80 characters
width.

diff -r 0a176990243c -r 1c9bc6a66fc3 mercurial/posix.py
--- a/mercurial/posix.py        Sun May 13 14:29:05 2012 +0200
+++ b/mercurial/posix.py        Mon May 14 13:25:42 2012 +0100
@@ -409,10 +409,13 @@
                     continue
                 if not os.isatty(fd):
                     continue
-                arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8)
-                width = array.array('h', arri)[1]
-                if width > 0:
-                    return width
+                try:
+                    arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8)
+                    width = array.array('h', arri)[1]
+                    if width > 0:
+                        return width
+                except AttributeError:
+                    pass
             except ValueError:
                 pass
             except IOError, e:


More information about the Mercurial-devel mailing list