# HG changeset patch # User Vsevolod Solovyov # Date 1237937335 0 # Node ID 6ea0318daf75b0b0b998f22f0cc33a8c2ba22905 # Parent fd22d7c7b3021848ce1a9ff6d709c4f093b169ab Fix issue1495, corner case of adding empty files via patching diff -r fd22d7c7b302 -r 6ea0318daf75 mercurial/patch.py --- a/mercurial/patch.py Fri Apr 03 11:50:42 2009 -0500 +++ b/mercurial/patch.py Tue Mar 24 23:28:55 2009 +0000 @@ -910,7 +910,7 @@ # else error? # copy/rename + modify should modify target, not source gp = changed.get(bfile) - if gp and gp.op in ('COPY', 'DELETE', 'RENAME'): + if gp and gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD'): afile = bfile gitworkdone = True newfile = True diff -r fd22d7c7b302 -r 6ea0318daf75 tests/test-import --- a/tests/test-import Fri Apr 03 11:50:42 2009 -0500 +++ b/tests/test-import Tue Mar 24 23:28:55 2009 +0000 @@ -313,3 +313,22 @@ hg import --no-commit -v -s 100 ../rename.diff hg st -C cd .. + + +echo '% add empty file from the end of patch (issue 1495)' +hg init addemptyend +cd addemptyend +touch a +hg addremove +hg ci -m "commit" +cat > a.patch <