diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -933,8 +933,10 @@ def selectfile(afile_orig, bfile_orig, h 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(): diff --git a/tests/test-import b/tests/test-import --- a/tests/test-import +++ b/tests/test-import @@ -351,10 +351,22 @@ diff -Naur proj-orig/foo proj-new/foo @@ -0,0 +1,1 @@ +a EOF +# some people have patches like the following too +cat > create2.patch <