topic: migrate experimental.enforce-topic to experimental.topic-mode
authorBoris Feld <boris.feld@octobus.net>
Sat, 30 Sep 2017 22:24:24 +0100
changeset 3020 361d83261d7a
parent 3019 dd3eda2f7a89
child 3021 5f4c42d4f2e8
topic: migrate experimental.enforce-topic to experimental.topic-mode
hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py	Sat Sep 30 12:35:49 2017 +0100
+++ b/hgext3rd/topic/__init__.py	Sat Sep 30 22:24:24 2017 +0100
@@ -875,14 +875,27 @@
     # i18n: column positioning for "hg summary"
     ui.write(_("topic:  %s\n") % ui.label(t, 'topic.active'))
 
+def _configtopicmode(ui):
+    """ Parse the config to get the topicmode
+    """
+    topicmode = ui.config('experimental', 'topic-mode', default=None)
+
+    # Fallback to read enforce-topic
+    if topicmode is None:
+        enforcetopic = ui.configbool('experimental', 'enforce-topic')
+        if enforcetopic:
+            topicmode = "enforce"
+
+    return topicmode
+
 def commitwrap(orig, ui, repo, *args, **opts):
     with repo.wlock():
-        enforcetopic = ui.configbool('experimental', 'enforce-topic')
+        topicmode = _configtopicmode(ui)
         if opts.get('topic'):
             t = opts['topic']
             with repo.vfs.open('topic', 'w') as f:
                 f.write(t)
-        elif not repo.currenttopic and enforcetopic:
+        elif not repo.currenttopic and topicmode == "enforce":
             msg = _("no active topic")
             hint = _("set a current topic or use '--config " +
                      "experimental.enforce-topic=no' to commit without a topic")