# HG changeset patch # User Yuya Nishihara # Date 1509806759 -32400 # Node ID 0ba3b928f9a994a39c88cda2bba0e05a0a612ab8 # Parent b69c700b6de69f844e5aa64b60bc87f944dcd587 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. diff -r b69c700b6de6 -r 0ba3b928f9a9 mercurial/cmdutil.py --- 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(), diff -r b69c700b6de6 -r 0ba3b928f9a9 tests/test-amend.t --- 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