diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1337,8 +1337,10 @@ class workingctx(committablectx): else: wlock = self._repo.wlock() try: - if self._repo.dirstate[dest] in '?r': + if self._repo.dirstate[dest] in '?': self._repo.dirstate.add(dest) + elif self._repo.dirstate[dest] in 'r': + self._repo.dirstate.normallookup(dest) self._repo.dirstate.copy(source, dest) finally: wlock.release() diff --git a/tests/test-mq-qrename.t b/tests/test-mq-qrename.t --- a/tests/test-mq-qrename.t +++ b/tests/test-mq-qrename.t @@ -76,8 +76,8 @@ Test overlapping renames (issue2388) $ hg qrename patchb patchc $ hg qrename patcha patchb $ hg st --mq + M patchb M series - A patchb A patchc R patcha $ cd .. diff --git a/tests/test-rename.t b/tests/test-rename.t --- a/tests/test-rename.t +++ b/tests/test-rename.t @@ -571,15 +571,24 @@ overwriting with renames (issue1959) $ hg rename d1/a d1/c $ hg rename d1/b d1/a $ hg status -C - A d1/a + M d1/a d1/b A d1/c d1/a R d1/b $ hg diff --git - diff --git a/d1/b b/d1/a - rename from d1/b - rename to d1/a + diff --git a/d1/a b/d1/a + --- a/d1/a + +++ b/d1/a + @@ -1,1 +1,1 @@ + -d1/a + +d1/b + diff --git a/d1/b b/d1/b + deleted file mode 100644 + --- a/d1/b + +++ /dev/null + @@ -1,1 +0,0 @@ + -d1/b diff --git a/d1/a b/d1/c copy from d1/a copy to d1/c diff --git a/tests/test-status.t b/tests/test-status.t --- a/tests/test-status.t +++ b/tests/test-status.t @@ -390,3 +390,49 @@ warning message about such pattern. #endif $ cd .. + +Status after move overwriting a file (issue4458) +================================================= + + + $ hg init issue4458 + $ cd issue4458 + $ echo a > a + $ echo b > b + $ hg commit -Am base + adding a + adding b + + +with --force + + $ hg mv b --force a + $ hg st --copies + M a + b + R b + $ hg revert --all + reverting a + undeleting b + $ rm *.orig + +without force + + $ hg rm a + $ hg st --copies + R a + $ hg mv b a + $ hg st --copies + M a + b + R b + +Other "bug" highlight, the revision status does not report the copy information. +This is buggy behavior. + + $ hg commit -m 'blah' + $ hg st --copies --change . + M a + R b + + $ cd ..