Mercurial > hg > mercurial-source
changeset 6179:36ab165abbe2
patch: fix iterhunks() with trailing binary file removal
Like some renames or copy operations, binary file removal does not generate any
"file" or "hunk" action, but was not tagged as such and let iterhunk() assume
no hunk was applied for the deleted file.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Thu, 28 Feb 2008 00:07:37 +0100 |
parents | 81afdd016867 |
children | d98ef03893e6 |
files | mercurial/patch.py tests/test-import tests/test-import.out |
diffstat | 3 files changed, 32 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -890,6 +890,9 @@ context = None lr = linereader(fp) dopatch = True + # gitworkdone is True if a git operation (copy, rename, ...) was + # performed already for the current file. Useful when the file + # section may have no hunk. gitworkdone = False while True: @@ -938,8 +941,8 @@ changed[gp.path] = (gp.op, gp) # else error? # copy/rename + modify should modify target, not source - if changed.get(bfile[2:], (None, None))[0] in ('COPY', - 'RENAME'): + gitop = changed.get(bfile[2:], (None, None))[0] + if gitop in ('COPY', 'DELETE', 'RENAME'): afile = bfile gitworkdone = True newfile = True
--- a/tests/test-import +++ b/tests/test-import @@ -207,3 +207,21 @@ done cd .. +# Test importing a patch ending with a binary file removal +echo % test trailing binary removal +hg init binaryremoval +cd binaryremoval +echo a > a +python -c "file('b', 'wb').write('a\x00b')" +hg ci -Am addall +hg rm a +hg rm b +hg st +hg ci -m remove +hg export --git . > remove.diff +cat remove.diff | grep git +hg up -C 0 +hg import remove.diff +hg manifest +cd .. +