# HG changeset patch # User Yuya Nishihara # Date 1509806899 -32400 # Node ID 5f40efa472db2373df23ae515fa49738ac917a78 # Parent 0ba3b928f9a994a39c88cda2bba0e05a0a612ab8 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. diff -r 0ba3b928f9a9 -r 5f40efa472db mercurial/cmdutil.py --- 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: diff -r 0ba3b928f9a9 -r 5f40efa472db tests/test-amend.t --- 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