##// END OF EJS Templates
amend: check for file modifications when updating dirstate (issue6233)...
Kyle Lippincott -
r44238:5558e343 default
parent child Browse files
Show More
@@ -3054,11 +3054,13 b' def amend(ui, repo, old, extra, pats, op'
3054 3054 # selectively update the dirstate only for the amended files.
3055 3055 dirstate = repo.dirstate
3056 3056
3057 # Update the state of the files which were added and
3058 # and modified in the amend to "normal" in the dirstate.
3057 # Update the state of the files which were added and modified in the
3058 # amend to "normal" in the dirstate. We need to use "normallookup" since
3059 # the files may have changed since the command started; using "normal"
3060 # would mark them as clean but with uncommitted contents.
3059 3061 normalfiles = set(wctx.modified() + wctx.added()) & filestoamend
3060 3062 for f in normalfiles:
3061 dirstate.normal(f)
3063 dirstate.normallookup(f)
3062 3064
3063 3065 # Update the state of files which were removed in the amend
3064 3066 # to "removed" in the dirstate.
@@ -476,3 +476,33 b' hg used to include the changes to `a` an'
476 476 a | 2 +-
477 477 b | 2 +-
478 478 2 files changed, 2 insertions(+), 2 deletions(-)
479
480 Modifying a file while the editor is open can cause dirstate corruption
481 (issue6233)
482
483 $ cd $TESTTMP
484 $ hg init modify-during-amend; cd modify-during-amend
485 $ echo r0 > foo; hg commit -qAm "r0"
486 $ echo alpha > foo; hg commit -qm "alpha"
487 $ echo beta >> foo
488 $ cat > $TESTTMP/sleepy_editor.sh <<EOF
489 > echo hi > "\$1"
490 > sleep 3
491 > EOF
492 $ HGEDITOR="sh $TESTTMP/sleepy_editor.sh" hg commit --amend &
493 $ sleep 1
494 $ echo delta >> foo
495 $ sleep 3
496 $ if (hg diff -c . | grep 'delta' >/dev/null) || [[ -n "$(hg status)" ]]; then
497 > echo "OK."
498 > else
499 > echo "Bug detected. 'delta' is not part of the commit OR the wdir"
500 > echo "Diff and status before rebuild:"
501 > hg diff
502 > hg status
503 > hg debugrebuilddirstate
504 > echo "Diff and status after rebuild:"
505 > hg diff
506 > hg status
507 > fi
508 OK.
General Comments 0
You need to be logged in to leave comments. Login now