Mercurial > hg > mercurial-crew-with-dirclash
diff mercurial/util.py @ 2579:0875cda033fd
use __contains__, index or split instead of str.find
str.find return -1 when the substring is not found, -1 evaluate
to True and is a valid index, which can lead to bugs.
Using alternatives when possible makes the code clearer and less
prone to bugs. (and __contains__ is faster in microbenchmarks)
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sun, 09 Jul 2006 01:30:30 +0200 |
parents | 8cb894370514 |
children | 00fc88b0b256 |
line wrap: on
line diff
--- a/mercurial/util.py +++ b/mercurial/util.py @@ -620,7 +620,7 @@ else: def parse_patch_output(output_line): """parses the output produced by patch and returns the file name""" pf = output_line[14:] - if pf.startswith("'") and pf.endswith("'") and pf.find(" ") >= 0: + if pf.startswith("'") and pf.endswith("'") and " " in pf: pf = pf[1:-1] # Remove the quotes return pf