# HG changeset patch # User FUJIWARA Katsunori # Date 2014-12-17 06:09:43 # Node ID 200215cdf7aa9a75054ae7d4f840bb8c3551c23d # Parent 87a76cff7147f870c1b22cb2730040b4b34a936c memctx: calculate manifest correctly with newly-removed files (issue4470) Before this patch, "memctx._manifest" tries to get (and use normally) filectx also for newly-removed files, even though "memctx.filectx()" returns None for such files. To calculate manifest correctly even with newly-removed files, this patch does: - replace "man.iteritems()" for the loop by "self._status.modified" to avoid accessing itself to newly removed files this also reduces loop cost for large manifest. - remove files in "self._status.removed" from the manifest In this patch, amending is confirmed twice to examine both (1) newly removed files and (2) ones already removed in amended revision. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1649,6 +1649,10 @@ class memctx(committablectx): for f in self._status.added: man[f] = revlog.hash(self[f].data(), nullid, nullid) + for f in self._status.removed: + if f in man: + del man[f] + return man @propertycache diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t --- a/tests/test-commit-amend.t +++ b/tests/test-commit-amend.t @@ -905,6 +905,58 @@ Test that "diff()" in committemplate wor HG: @@ -0,0 +1,1 @@ HG: +y + $ hg rm a + $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo and y" + expecting diff of a, foo and y + + HG: M: + HG: A: foo y + HG: R: a + HG: diff -r 6de0c1bde1c8 a + HG: --- a/a Thu Jan 01 00:00:00 1970 +0000 + HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 + HG: @@ -1,2 +0,0 @@ + HG: -a + HG: -a + HG: diff -r 6de0c1bde1c8 foo + HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000 + HG: @@ -0,0 +1,1 @@ + HG: +foo + HG: diff -r 6de0c1bde1c8 y + HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000 + HG: @@ -0,0 +1,1 @@ + HG: +y + + $ hg rm x + $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo, x and y" + expecting diff of a, foo, x and y + + HG: M: + HG: A: foo y + HG: R: a x + HG: diff -r 6de0c1bde1c8 a + HG: --- a/a Thu Jan 01 00:00:00 1970 +0000 + HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 + HG: @@ -1,2 +0,0 @@ + HG: -a + HG: -a + HG: diff -r 6de0c1bde1c8 foo + HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000 + HG: @@ -0,0 +1,1 @@ + HG: +foo + HG: diff -r 6de0c1bde1c8 x + HG: --- a/x Thu Jan 01 00:00:00 1970 +0000 + HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 + HG: @@ -1,1 +0,0 @@ + HG: -x + HG: diff -r 6de0c1bde1c8 y + HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000 + HG: @@ -0,0 +1,1 @@ + HG: +y Check for issue4405 -------------------