Mercurial > public > mercurial-scm > hg-stable
diff mercurial/patch.py @ 10745:d94832c4a31d stable
patch: try harder to find the file to patch on file creation (issue2041)
accept the following patch header:
first line: foo/a.orig
second line: foo/a
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Fri, 19 Mar 2010 22:52:38 +0100 |
parents | a528a1046dba |
children | 16b9aa398c28 b010d899665e |
line wrap: on
line diff
--- a/mercurial/patch.py Fri Mar 19 16:04:00 2010 -0500 +++ b/mercurial/patch.py Fri Mar 19 22:52:38 2010 +0100 @@ -933,8 +933,10 @@ missing = not goodb and not gooda and not createfunc() # some diff programs apparently produce create patches where the - # afile is not /dev/null, but rather the same name as the bfile - if missing and afile == bfile: + # afile is not /dev/null, but afile starts with bfile + abasedir = afile[:afile.rfind('/') + 1] + bbasedir = bfile[:bfile.rfind('/') + 1] + if missing and abasedir == bbasedir and afile.startswith(bfile): # this isn't very pretty hunk.create = True if createfunc():