amend: do not take untracked files as modified or clean (issue5732) stable
authorYuya Nishihara <yuya@tcha.org>
Sat, 04 Nov 2017 23:45:59 +0900
branchstable
changeset 34974 0ba3b928f9a9
parent 34973 b69c700b6de6
child 34975 5f40efa472db
amend: do not take untracked files as modified or clean (issue5732) fctx.exists() shouldn't be used here as it checks if a file physically exists, which may disagree with the dirstate.
mercurial/cmdutil.py
tests/test-amend.t
--- a/mercurial/cmdutil.py	Sat Nov 04 23:40:26 2017 +0900
+++ b/mercurial/cmdutil.py	Sat Nov 04 23:45:59 2017 +0900
@@ -3180,12 +3180,11 @@
                     if path not in filestoamend:
                         return old.filectx(path)
 
+                    # Return None for removed files.
+                    if path in wctx.removed():
+                        return None
+
                     fctx = wctx[path]
-
-                    # Return None for removed files.
-                    if not fctx.exists():
-                        return None
-
                     flags = fctx.flags()
                     mctx = context.memfilectx(repo,
                                               fctx.path(), fctx.data(),
--- a/tests/test-amend.t	Sat Nov 04 23:40:26 2017 +0900
+++ b/tests/test-amend.t	Sat Nov 04 23:45:59 2017 +0900
@@ -268,7 +268,6 @@
 
 clean/modified/removed/added states of the amended revision
 
-BROKEN: untracked files aren't removed
 BROKEN: missing files are removed
 
   $ hg status --all --change . 'glob:content1_*_content1-tracked'
@@ -285,21 +284,16 @@
   R content1_missing_missing-tracked
   C content1_content1_missing-tracked
   $ hg status --all --change . 'glob:content1_*_*-untracked'
-  M content1_content1_content3-untracked (true !)
-  M content1_content2_content2-untracked (true !)
-  M content1_content2_content3-untracked (true !)
-  R content1_content1_content1-untracked (false !)
-  R content1_content1_content3-untracked (false !)
+  R content1_content1_content1-untracked
+  R content1_content1_content3-untracked
   R content1_content1_missing-untracked
-  R content1_content2_content1-untracked (false !)
-  R content1_content2_content2-untracked (false !)
-  R content1_content2_content3-untracked (false !)
+  R content1_content2_content1-untracked
+  R content1_content2_content2-untracked
+  R content1_content2_content3-untracked
   R content1_content2_missing-untracked
   R content1_missing_content1-untracked
   R content1_missing_content3-untracked
   R content1_missing_missing-untracked
-  C content1_content1_content1-untracked (true !)
-  C content1_content2_content1-untracked (true !)
   $ hg status --all --change . 'glob:missing_content2_*'
   A missing_content2_content2-tracked
   A missing_content2_content3-tracked