hgext3rd/topic/__init__.py
changeset 3024 89855920fb0f
parent 3023 cc740c545776
child 3025 e814c553ef32
--- a/hgext3rd/topic/__init__.py	Sat Sep 30 23:00:21 2017 +0100
+++ b/hgext3rd/topic/__init__.py	Sat Sep 30 23:18:29 2017 +0100
@@ -59,7 +59,7 @@
     # behavior when commit is made without an active topic
     topic-mode = ignore # do nothing special (default)
     topic-mode = warning # print a warning
-    topic-mode = enforce # abort the commit
+    topic-mode = enforce # abort the commit (except for merge)
 """
 
 from __future__ import absolute_import
@@ -911,16 +911,23 @@
 def commitwrap(orig, ui, repo, *args, **opts):
     with repo.wlock():
         topicmode = _configtopicmode(ui)
+        ismergecommit = len(repo[None].parents()) == 2
+
+        notopic = not repo.currenttopic
+        mayabort = (topicmode == "enforce" and not ismergecommit)
+        maywarn = (topicmode == "warning"
+                   or (topicmode == "enforce" and ismergecommit))
+
         if opts.get('topic'):
             t = opts['topic']
             with repo.vfs.open('topic', 'w') as f:
                 f.write(t)
-        elif not repo.currenttopic and topicmode == "enforce":
+        elif notopic and mayabort:
             msg = _("no active topic")
             hint = _("set a current topic or use '--config " +
                      "experimental.topic-mode=off' to commit without a topic")
             raise error.Abort(msg, hint=hint)
-        elif not repo.currenttopic and topicmode == 'warning':
+        elif notopic and maywarn:
             ui.warn(_("warning: new draft commit without topic\n"))
         return orig(ui, repo, *args, **opts)