diff --git a/mercurial/patch.py b/mercurial/patch.py index 131d1a09108a702c58bf6c458675a0b24f667a39_bWVyY3VyaWFsL3BhdGNoLnB5..d7829b2ecf3274ca1b8306b993a38cf1b5c57ce3_bWVyY3VyaWFsL3BhdGNoLnB5 100644 --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -475,6 +475,5 @@ addremoved = set(self.changed) for src, dst in self.copied: scmutil.dirstatecopy(self.ui, self.repo, wctx, src, dst) - addremoved.discard(src) - if (not self.similarity) and self.removed: + if self.removed: wctx.forget(sorted(self.removed)) @@ -480,4 +479,11 @@ wctx.forget(sorted(self.removed)) + for f in self.removed: + if f not in self.repo.dirstate: + # File was deleted and no longer belongs to the + # dirstate, it was probably marked added then + # deleted, and should not be considered by + # addremove(). + addremoved.discard(f) if addremoved: cwd = self.repo.getcwd() if cwd: diff --git a/tests/test-import-git.t b/tests/test-import-git.t index 131d1a09108a702c58bf6c458675a0b24f667a39_dGVzdHMvdGVzdC1pbXBvcnQtZ2l0LnQ=..d7829b2ecf3274ca1b8306b993a38cf1b5c57ce3_dGVzdHMvdGVzdC1pbXBvcnQtZ2l0LnQ= 100644 --- a/tests/test-import-git.t +++ b/tests/test-import-git.t @@ -402,6 +402,23 @@ A b a R a + +Renames, similarity and git diff + + $ hg revert -aC + undeleting a + forgetting b + $ rm b + $ hg import --similarity 90 --no-commit - <<EOF + > diff --git a/a b/b + > rename from a + > rename to b + > EOF + applying patch from stdin + $ hg st --copies + A b + a + R a $ cd .. Pure copy with existing destination diff --git a/tests/test-import.t b/tests/test-import.t index 131d1a09108a702c58bf6c458675a0b24f667a39_dGVzdHMvdGVzdC1pbXBvcnQudA==..d7829b2ecf3274ca1b8306b993a38cf1b5c57ce3_dGVzdHMvdGVzdC1pbXBvcnQudA== 100644 --- a/tests/test-import.t +++ b/tests/test-import.t @@ -663,7 +663,6 @@ applying ../rename.diff patching file a patching file b - removing a adding b recording removal of a as rename to b (88% similar) applied to working directory @@ -679,7 +678,6 @@ applying ../rename.diff patching file a patching file b - removing a adding b applied to working directory $ hg st -C