hgext3rd/topic/__init__.py
changeset 3022 255e66783505
parent 3021 5f4c42d4f2e8
child 3023 cc740c545776
--- a/hgext3rd/topic/__init__.py	Sat Sep 30 22:42:52 2017 +0100
+++ b/hgext3rd/topic/__init__.py	Sun Oct 01 00:14:19 2017 +0100
@@ -48,6 +48,17 @@
 
 Be aware that this extension is still an experiment, commands and other features
 are likely to be change/adjusted/dropped over time as we refine the concept.
+
+Config option
+=============
+
+The topic extension can be configured to ensure the user do not forget to add
+a topic when committing a new topic::
+
+    [experimental]
+    # behavior when commit is made without an active topic
+    topic-mode = ignore # do nothing special (default)
+    topic-mode = enforce # abort the commit
 """
 
 from __future__ import absolute_import
@@ -875,6 +886,11 @@
     # i18n: column positioning for "hg summary"
     ui.write(_("topic:  %s\n") % ui.label(t, 'topic.active'))
 
+_validmode = [
+    'ignore',
+    'enforce',
+]
+
 def _configtopicmode(ui):
     """ Parse the config to get the topicmode
     """
@@ -885,6 +901,8 @@
         enforcetopic = ui.configbool('experimental', 'enforce-topic')
         if enforcetopic:
             topicmode = "enforce"
+    if topicmode not in _validmode:
+        topicmode = _validmode[0]
 
     return topicmode