diff tests/test-topicmode.t @ 3023:cc740c545776

topicmode: add new warning topicmode
author Boris Feld <boris.feld@octobus.net>
date Sat, 30 Sep 2017 23:00:21 +0100
parents
children 89855920fb0f
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-topicmode.t	Sat Sep 30 23:00:21 2017 +0100
@@ -0,0 +1,68 @@
+  $ . "$TESTDIR/testlib/topic_setup.sh"
+
+Testing the new config knob to forbid untopiced commit
+======================================================
+
+  $ hg init $TESTTMP/untopic-commit
+  $ cd $TESTTMP/untopic-commit
+  $ cat <<EOF >> .hg/hgrc
+  > [phases]
+  > publish=false
+  > EOF
+  $ cat <<EOF >> $HGRCPATH
+  > [experimental]
+  > topic-mode = enforce
+  > EOF
+  $ touch a b c d
+  $ hg add a
+  $ hg ci -m "Added a"
+  abort: no active topic
+  (set a current topic or use '--config experimental.topic-mode=off' to commit without a topic)
+  [255]
+
+(same test, checking we abort before the editor)
+
+  $ EDITOR=cat hg ci -m "Added a" --edit
+  abort: no active topic
+  (set a current topic or use '--config experimental.topic-mode=off' to commit without a topic)
+  [255]
+  $ hg ci -m "added a" --config experimental.topic-mode=off
+  $ hg log
+  changeset:   0:a154386e50d1
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     added a
+  
+
+Testing the new config knob to warn about untopiced commit
+==========================================================
+
+  $ hg init $TESTTMP/untopic-warn-commit
+  $ cd $TESTTMP/untopic-warn-commit
+  $ cat <<EOF >> .hg/hgrc
+  > [phases]
+  > publish=false
+  > EOF
+  $ cat <<EOF >> $HGRCPATH
+  > [experimental]
+  > topic-mode = warning
+  > EOF
+  $ touch a b c d
+  $ hg add a
+  $ hg ci -m "Added a"
+  warning: new draft commit without topic
+
+(same test, checking we abort before the editor)
+
+  $ EDITOR=cat hg ci --amend -m "Added a" --edit
+  warning: new draft commit without topic
+  $ hg ci --amend -m "added a'" --config experimental.topic-mode=off
+  $ hg log
+  changeset:   2:2e862d8b5eff
+  tag:         tip
+  parent:      -1:000000000000
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     added a'
+