Mercurial > hg
changeset 23402:2963d5c9d90b stable
rename: properly report removed and added file as modified (issue4458)
The result of 'hg rm' + 'hg rename' disagreed with the one from
'hg rename --force'. We align them on 'hg move --force' because it agrees with
what 'hg status' says after the commit.
Stopping reporting a modified file as added puts an end to the hg revert confusion in this
situation (issue4458).
However, reporting the file as modified also prevents revert from restoring the copy
source. We fix this in a later changeset.
Git diff also stop reporting the add in the middle of the chain as add. Not
sure how important (and even wrong) it is.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 24 Nov 2014 18:42:56 -0800 |
parents | fd1bab28a8cc |
children | edf29f9c15f0 |
files | mercurial/context.py tests/test-mq-qrename.t tests/test-rename.t tests/test-status.t |
diffstat | 4 files changed, 63 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Wed Nov 26 14:54:16 2014 -0800 +++ b/mercurial/context.py Mon Nov 24 18:42:56 2014 -0800 @@ -1337,8 +1337,10 @@ 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()
--- a/tests/test-mq-qrename.t Wed Nov 26 14:54:16 2014 -0800 +++ b/tests/test-mq-qrename.t Mon Nov 24 18:42:56 2014 -0800 @@ -76,8 +76,8 @@ $ hg qrename patchb patchc $ hg qrename patcha patchb $ hg st --mq + M patchb M series - A patchb A patchc R patcha $ cd ..
--- a/tests/test-rename.t Wed Nov 26 14:54:16 2014 -0800 +++ b/tests/test-rename.t Mon Nov 24 18:42:56 2014 -0800 @@ -571,15 +571,24 @@ $ 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
--- a/tests/test-status.t Wed Nov 26 14:54:16 2014 -0800 +++ b/tests/test-status.t Mon Nov 24 18:42:56 2014 -0800 @@ -390,3 +390,49 @@ #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 ..