patch: simplify Boolean expression slightly
authorMartin Geisler <mg@lazybytes.net>
Wed, 20 May 2009 00:43:23 +0200
changeset 8526 f78eadbb5769
parent 8525 b169ba60eebe
child 8527 f9a80054dd3c
patch: simplify Boolean expression slightly The context variable is either True, False or None. Abbreviate it as C and we get the following truth table where the second column is the original expression and the third column is the new expression: C | C or C == None | C is not False True | True | True False | False | False None | True | True
mercurial/patch.py
--- a/mercurial/patch.py	Tue May 05 10:29:34 2009 +0200
+++ b/mercurial/patch.py	Wed May 20 00:43:23 2009 +0200
@@ -870,7 +870,7 @@
             current_hunk = None
             gitworkdone = False
         if ((sourcefile or state == BFILE) and ((not context and x[0] == '@') or
-            ((context or context == None) and x.startswith('***************')))):
+            ((context is not False) and x.startswith('***************')))):
             try:
                 if context == None and x.startswith('***************'):
                     context = True