Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 8526:f78eadbb5769
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
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Wed, 20 May 2009 00:43:23 +0200 |
parents | 88f317e7d280 |
children | f9a80054dd3c |
comparison
equal
deleted
inserted
replaced
8525:b169ba60eebe | 8526:f78eadbb5769 |
---|---|
868 current_hunk.fix_newline() | 868 current_hunk.fix_newline() |
869 yield 'hunk', current_hunk | 869 yield 'hunk', current_hunk |
870 current_hunk = None | 870 current_hunk = None |
871 gitworkdone = False | 871 gitworkdone = False |
872 if ((sourcefile or state == BFILE) and ((not context and x[0] == '@') or | 872 if ((sourcefile or state == BFILE) and ((not context and x[0] == '@') or |
873 ((context or context == None) and x.startswith('***************')))): | 873 ((context is not False) and x.startswith('***************')))): |
874 try: | 874 try: |
875 if context == None and x.startswith('***************'): | 875 if context == None and x.startswith('***************'): |
876 context = True | 876 context = True |
877 gpatch = changed.get(bfile) | 877 gpatch = changed.get(bfile) |
878 create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD' | 878 create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD' |