amend: do not drop missing files (issue5732)
samefile() can be wrong since wctx.manifest() does not include missing files,
whereas missing files should be preserved on commit.
--- a/mercurial/cmdutil.py Sat Nov 04 23:45:59 2017 +0900
+++ b/mercurial/cmdutil.py Sat Nov 04 23:48:19 2017 +0900
@@ -3166,9 +3166,11 @@
# introduced file X and the file was renamed in the working
# copy, then those two files are the same and
# we can discard X from our list of files. Likewise if X
- # was deleted, it's no longer relevant
+ # was removed, it's no longer relevant. If X is missing (aka
+ # deleted), old X must be preserved.
files.update(filestoamend)
- files = [f for f in files if not samefile(f, wctx, base)]
+ files = [f for f in files if (not samefile(f, wctx, base)
+ or f in wctx.deleted())]
def filectxfn(repo, ctx_, path):
try:
--- a/tests/test-amend.t Sat Nov 04 23:45:59 2017 +0900
+++ b/tests/test-amend.t Sat Nov 04 23:48:19 2017 +0900
@@ -268,8 +268,6 @@
clean/modified/removed/added states of the amended revision
-BROKEN: missing files are removed
-
$ hg status --all --change . 'glob:content1_*_content1-tracked'
C content1_content1_content1-tracked
C content1_content2_content1-tracked
@@ -297,7 +295,7 @@
$ hg status --all --change . 'glob:missing_content2_*'
A missing_content2_content2-tracked
A missing_content2_content3-tracked
- A missing_content2_missing-tracked (false !)
+ A missing_content2_missing-tracked
$ hg status --all --change . 'glob:missing_missing_*'
A missing_missing_content3-tracked