--- a/tests/test-amend.t Thu Dec 05 09:39:49 2019 -0800
+++ b/tests/test-amend.t Tue Nov 26 16:10:21 2019 -0800
@@ -476,3 +476,33 @@
a | 2 +-
b | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
+
+Modifying a file while the editor is open can cause dirstate corruption
+(issue6233)
+
+ $ cd $TESTTMP
+ $ hg init modify-during-amend; cd modify-during-amend
+ $ echo r0 > foo; hg commit -qAm "r0"
+ $ echo alpha > foo; hg commit -qm "alpha"
+ $ echo beta >> foo
+ $ cat > $TESTTMP/sleepy_editor.sh <<EOF
+ > echo hi > "\$1"
+ > sleep 3
+ > EOF
+ $ HGEDITOR="sh $TESTTMP/sleepy_editor.sh" hg commit --amend &
+ $ sleep 1
+ $ echo delta >> foo
+ $ sleep 3
+ $ if (hg diff -c . | grep 'delta' >/dev/null) || [[ -n "$(hg status)" ]]; then
+ > echo "OK."
+ > else
+ > echo "Bug detected. 'delta' is not part of the commit OR the wdir"
+ > echo "Diff and status before rebuild:"
+ > hg diff
+ > hg status
+ > hg debugrebuilddirstate
+ > echo "Diff and status after rebuild:"
+ > hg diff
+ > hg status
+ > fi
+ OK.