diff --git a/mercurial/scmposix.py b/mercurial/scmposix.py
index 80708959161a2cf7cd72835aceef07f3b7072c72_bWVyY3VyaWFsL3NjbXBvc2l4LnB5..1ad1c50170430cd07db561a61f90add04e5bf3f8_bWVyY3VyaWFsL3NjbXBvc2l4LnB5 100644
--- a/mercurial/scmposix.py
+++ b/mercurial/scmposix.py
@@ -48,6 +48,7 @@
         TIOCGWINSZ = termios.TIOCGWINSZ  # unavailable on IRIX (issue3449)
     except (AttributeError, ImportError):
         return 80
-    if True:
-        for dev in (ui.ferr, ui.fout, ui.fin):
+
+    for dev in (ui.ferr, ui.fout, ui.fin):
+        try:
             try:
@@ -53,14 +54,15 @@
             try:
-                try:
-                    fd = dev.fileno()
-                except AttributeError:
-                    continue
-                if not os.isatty(fd):
-                    continue
-                if True:
-                    arri = fcntl.ioctl(fd, TIOCGWINSZ, '\0' * 8)
-                    width = array.array('h', arri)[1]
-                    if width > 0:
-                        return width
-            except ValueError:
+                fd = dev.fileno()
+            except AttributeError:
+                continue
+            if not os.isatty(fd):
+                continue
+            arri = fcntl.ioctl(fd, TIOCGWINSZ, '\0' * 8)
+            width = array.array('h', arri)[1]
+            if width > 0:
+                return width
+        except ValueError:
+            pass
+        except IOError as e:
+            if e[0] == errno.EINVAL:
                 pass
@@ -66,7 +68,4 @@
                 pass
-            except IOError as e:
-                if e[0] == errno.EINVAL:
-                    pass
-                else:
-                    raise
+            else:
+                raise
     return 80