Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 5651:e11940d84606
patch: avoid file existence tests when possible in selectfile()
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Mon, 17 Dec 2007 23:06:04 +0100 |
parents | 5d3e2f918d65 |
children | e90e72c6b4c7 |
comparison
equal
deleted
inserted
replaced
5650:5d3e2f918d65 | 5651:e11940d84606 |
---|---|
794 return path[i:].rstrip() | 794 return path[i:].rstrip() |
795 | 795 |
796 nulla = afile_orig == "/dev/null" | 796 nulla = afile_orig == "/dev/null" |
797 nullb = bfile_orig == "/dev/null" | 797 nullb = bfile_orig == "/dev/null" |
798 afile = pathstrip(afile_orig, strip) | 798 afile = pathstrip(afile_orig, strip) |
799 gooda = os.path.exists(afile) and not nulla | 799 gooda = not nulla and os.path.exists(afile) |
800 bfile = pathstrip(bfile_orig, strip) | 800 bfile = pathstrip(bfile_orig, strip) |
801 if afile == bfile: | 801 if afile == bfile: |
802 goodb = gooda | 802 goodb = gooda |
803 else: | 803 else: |
804 goodb = os.path.exists(bfile) and not nullb | 804 goodb = not nullb and os.path.exists(bfile) |
805 createfunc = hunk.createfile | 805 createfunc = hunk.createfile |
806 if reverse: | 806 if reverse: |
807 createfunc = hunk.rmfile | 807 createfunc = hunk.rmfile |
808 if not goodb and not gooda and not createfunc(): | 808 if not goodb and not gooda and not createfunc(): |
809 raise PatchError(_("unable to find %s or %s for patching") % | 809 raise PatchError(_("unable to find %s or %s for patching") % |