[PATCH 3 of 6 STABLE] amend: do not drop missing files (issue5732)

Yuya Nishihara yuya at tcha.org
Wed Nov 8 08:13:52 EST 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1509806899 -32400
#      Sat Nov 04 23:48:19 2017 +0900
# Branch stable
# Node ID 53b507cba99d5fe71a5a018cba1c0ab67d64ce79
# Parent  bbdfaa3d4dc9ca3293065cfdaa611e95e6aa8cc6
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 --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3166,9 +3166,11 @@ def amend(ui, repo, old, extra, pats, op
             # 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 --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -268,8 +268,6 @@ amend r1 to include wc changes
 
 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 @@ BROKEN: missing files are removed
   $ 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
 


More information about the Mercurial-devel mailing list