patch: avoid file existence tests when possible in selectfile()

This commit is contained in:
Patrick Mezard 2007-12-17 23:06:04 +01:00
parent c43b58242b
commit 29045b226b

View File

@ -796,12 +796,12 @@ def selectfile(afile_orig, bfile_orig, hunk, strip, reverse):
nulla = afile_orig == "/dev/null"
nullb = bfile_orig == "/dev/null"
afile = pathstrip(afile_orig, strip)
gooda = os.path.exists(afile) and not nulla
gooda = not nulla and os.path.exists(afile)
bfile = pathstrip(bfile_orig, strip)
if afile == bfile:
goodb = gooda
else:
goodb = os.path.exists(bfile) and not nullb
goodb = not nullb and os.path.exists(bfile)
createfunc = hunk.createfile
if reverse:
createfunc = hunk.rmfile