diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1158,14 +1158,12 @@ def iterhunks(fp): 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 --git a/tests/test-git-import.t b/tests/test-git-import.t --- a/tests/test-git-import.t +++ b/tests/test-git-import.t @@ -383,3 +383,22 @@ Consecutive import with renames (issue24 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 ..