##// END OF EJS Templates
patch: try harder to find the file to patch on file creation (issue2041)...
Benoit Boissinot -
r10745:d94832c4 stable
parent child Browse files
Show More
@@ -933,8 +933,10 b' def selectfile(afile_orig, bfile_orig, h'
933 missing = not goodb and not gooda and not createfunc()
933 missing = not goodb and not gooda and not createfunc()
934
934
935 # some diff programs apparently produce create patches where the
935 # some diff programs apparently produce create patches where the
936 # afile is not /dev/null, but rather the same name as the bfile
936 # afile is not /dev/null, but afile starts with bfile
937 if missing and afile == bfile:
937 abasedir = afile[:afile.rfind('/') + 1]
938 bbasedir = bfile[:bfile.rfind('/') + 1]
939 if missing and abasedir == bbasedir and afile.startswith(bfile):
938 # this isn't very pretty
940 # this isn't very pretty
939 hunk.create = True
941 hunk.create = True
940 if createfunc():
942 if createfunc():
@@ -351,10 +351,22 b' diff -Naur proj-orig/foo proj-new/foo'
351 @@ -0,0 +1,1 @@
351 @@ -0,0 +1,1 @@
352 +a
352 +a
353 EOF
353 EOF
354 # some people have patches like the following too
355 cat > create2.patch <<EOF
356 diff -Naur proj-orig/foo proj-new/foo
357 --- proj-orig/foo.orig 1969-12-31 16:00:00.000000000 -0800
358 +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700
359 @@ -0,0 +1,1 @@
360 +a
361 EOF
354 hg init oddcreate
362 hg init oddcreate
355 cd oddcreate
363 cd oddcreate
356 hg import --no-commit ../create.patch
364 hg import --no-commit ../create.patch
357 cat foo
365 cat foo
366 rm foo
367 hg revert foo
368 hg import --no-commit ../create2.patch
369 cat foo
358
370
359 echo % 'first line mistaken for email headers (issue 1859)'
371 echo % 'first line mistaken for email headers (issue 1859)'
360 hg init emailconfusion
372 hg init emailconfusion
@@ -305,6 +305,8 b' applying a.patch'
305 % create file when source is not /dev/null
305 % create file when source is not /dev/null
306 applying ../create.patch
306 applying ../create.patch
307 a
307 a
308 applying ../create2.patch
309 a
308 % first line mistaken for email headers (issue 1859)
310 % first line mistaken for email headers (issue 1859)
309 applying a.patch
311 applying a.patch
310 changeset: 0:5a681217c0ad
312 changeset: 0:5a681217c0ad
General Comments 0
You need to be logged in to leave comments. Login now