# HG changeset patch # User Patrick Mezard # Date 1305837841 -7200 # Node ID 7709cc9830255be66290f5ae02391c7dcd80a98a # Parent 9d59c596eb9e2e1f115c3f54584860607cb28b9b patch: git metadata was ignored if strip > 1 gitpatch objects emitted by iterhunks() are modified in place by applydiff(). Processing them earlier improves iterhunks() isolation. applydiff() modifying them should still be fixed though. diff -r 9d59c596eb9e -r 7709cc983025 mercurial/patch.py --- a/mercurial/patch.py Thu May 19 22:44:01 2011 +0200 +++ b/mercurial/patch.py Thu May 19 22:44:01 2011 +0200 @@ -1158,14 +1158,12 @@ if not git: git = True gitpatches = scangitpatch(lr, x) - yield 'git', gitpatches for gp in gitpatches: changed[gp.path] = gp - # else error? + yield 'git', gitpatches # copy/rename + modify should modify target, not source - gp = changed.get(bfile) - if gp and (gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD') - or gp.mode): + gp = changed[bfile] + if gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD') or gp.mode: afile = bfile newfile = True elif x.startswith('---'): diff -r 9d59c596eb9e -r 7709cc983025 tests/test-git-import.t --- a/tests/test-git-import.t Thu May 19 22:44:01 2011 +0200 +++ b/tests/test-git-import.t Thu May 19 22:44:01 2011 +0200 @@ -383,3 +383,22 @@ a 0 -1 unset b $ hg ci -m done $ cd .. + +Renames and strip + + $ hg init renameandstrip + $ cd renameandstrip + $ echo a > a + $ hg ci -Am adda + adding a + $ hg import --no-commit -p2 - < diff --git a/foo/a b/foo/b + > rename from foo/a + > rename to foo/b + > EOF + applying patch from stdin + $ hg st --copies + A b + a + R a + $ cd ..