[PATCH 4 of 7] scmutil: remove superfluous indent from termwidth()

Yuya Nishihara yuya at tcha.org
Fri Nov 4 03:48:59 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1476968252 -32400
#      Thu Oct 20 21:57:32 2016 +0900
# Node ID e62366ab7b244ce64e86935783a061f791c59281
# Parent  96aa6ffa3be75ea5a4fa9fe2d0440758d744b6af
# EXP-Topic stdio
scmutil: remove superfluous indent from termwidth()

diff --git a/mercurial/scmposix.py b/mercurial/scmposix.py
--- a/mercurial/scmposix.py
+++ b/mercurial/scmposix.py
@@ -48,25 +48,24 @@ def termwidth(ui):
         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:
-                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
-            except IOError as e:
-                if e[0] == errno.EINVAL:
-                    pass
-                else:
-                    raise
+            else:
+                raise
     return 80


More information about the Mercurial-devel mailing list