[PATCH 4 of 5] match: join two nested if-blocks

Martin von Zweigbergk martinvonz at google.com
Mon Jun 15 12:13:53 CDT 2015


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1433103461 25200
#      Sun May 31 13:17:41 2015 -0700
# Node ID aeee4bc1da3e3aa6acb284d5da1a4cbef9e3d10b
# Parent  84c443448e36de7bda8ec85dc1c96d539712b5f3
match: join two nested if-blocks

Instead of

  if a:
      if b:
          return False

let's write it

  if a and b:
      return False

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -226,10 +226,10 @@
             return False
         if (self._includeroots and
             dir not in self._includeroots and
-            dir not in self._includedirs):
-            if not any(parent in self._includeroots
-                       for parent in util.finddirs(dir)):
-                return False
+            dir not in self._includedirs and
+            not any(parent in self._includeroots
+                    for parent in util.finddirs(dir))):
+            return False
         return (not self._fileroots or
                 '.' in self._fileroots or
                 dir in self._fileroots or


More information about the Mercurial-devel mailing list