mercurial/util.py
branchstable
changeset 11010 18e81d42ee5c
parent 10901 997173e49115
child 11011 648130161e4d
child 11254 640d419725d0
--- a/mercurial/util.py	Tue Apr 27 00:44:06 2010 +0530
+++ b/mercurial/util.py	Mon Apr 26 22:30:40 2010 +0200
@@ -1245,35 +1245,6 @@
     # Avoid double backslash in Windows path repr()
     return repr(s).replace('\\\\', '\\')
 
-def termwidth():
-    if 'COLUMNS' in os.environ:
-        try:
-            return int(os.environ['COLUMNS'])
-        except ValueError:
-            pass
-    try:
-        import termios, array, fcntl
-        for dev in (sys.stderr, sys.stdout, sys.stdin):
-            try:
-                try:
-                    fd = dev.fileno()
-                except AttributeError:
-                    continue
-                if not os.isatty(fd):
-                    continue
-                arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8)
-                return array.array('h', arri)[1]
-            except ValueError:
-                pass
-            except IOError, e:
-                if e[0] == errno.EINVAL:
-                    pass
-                else:
-                    raise
-    except ImportError:
-        pass
-    return 80
-
 def wrap(line, hangindent, width=None):
     if width is None:
         width = termwidth() - 2
@@ -1357,3 +1328,11 @@
             if not i:
                 return False
         return True
+
+def termwidth():
+    if 'COLUMNS' in os.environ:
+        try:
+            return int(os.environ['COLUMNS'])
+        except ValueError:
+            pass
+    return termwidth_()