Patchwork [2,of,6,STABLE] amend: do not take untracked files as modified or clean (issue5732)

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 8, 2017, 1:13 p.m.
Message ID <bbdfaa3d4dc9ca329306.1510146831@mimosa>
Download mbox | patch
Permalink /patch/25415/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 8, 2017, 1:13 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1509806759 -32400
#      Sat Nov 04 23:45:59 2017 +0900
# Branch stable
# Node ID bbdfaa3d4dc9ca3293065cfdaa611e95e6aa8cc6
# Parent  a300140d16436606c8fd73f82dd7c8943de38240
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.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3180,12 +3180,11 @@  def amend(ui, repo, old, extra, pats, op
                     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(),
diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -268,7 +268,6 @@  amend r1 to include wc changes
 
 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 @@  BROKEN: missing files are removed
   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