diff tests/test-commit.t @ 20765:f042d4b263f4 stable

localrepo: save manually edited commit message as soon as possible Before this patch, "localrepository.commit()" invokes specified "editor" to edit commit message manually, and saves it after checking sub-repositories. This may lose manually edited commit message, if unexpected exception is raised while checking (or commiting recursively) sub-repositories. This patch saves manually edited commit message as soon as possible.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 19 Mar 2014 01:07:41 +0900
parents 94317c2d53b8
children efbf15979538 e259d4c462b5
line wrap: on
line diff
--- a/tests/test-commit.t	Thu Mar 13 19:48:41 2014 +0900
+++ b/tests/test-commit.t	Wed Mar 19 01:07:41 2014 +0900
@@ -284,6 +284,52 @@
   HG: removed removed
   abort: empty commit message
   [255]
+
+test saving last-message.txt
+
+  $ hg init sub
+  $ echo a > sub/a
+  $ hg -R sub add sub/a
+  $ cat > sub/.hg/hgrc <<EOF
+  > [hooks]
+  > precommit.test-saving-last-message = false
+  > EOF
+
+  $ echo 'sub = sub' > .hgsub
+  $ hg add .hgsub
+
+  $ cat > $TESTDIR/editor.sh <<EOF
+  > echo "==== before editing:"
+  > cat \$1
+  > echo "===="
+  > echo "test saving last-message.txt" >> \$1
+  > EOF
+
+  $ rm -f .hg/last-message.txt
+  $ HGEDITOR="sh $TESTDIR/editor.sh" hg commit -S -q
+  ==== before editing:
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: test
+  HG: branch 'default'
+  HG: bookmark 'currentbookmark'
+  HG: subrepo sub
+  HG: added .hgsub
+  HG: added added
+  HG: changed .hgsubstate
+  HG: changed changed
+  HG: removed removed
+  ====
+  abort: precommit.test-saving-last-message hook exited with status 1 (in subrepo sub)
+  [255]
+  $ cat .hg/last-message.txt
+  
+  
+  test saving last-message.txt
+
   $ cd ..