topic: add a 'enforce-all' mode
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 01 Oct 2017 00:44:41 +0100
changeset 3025 e814c553ef32
parent 3024 89855920fb0f
child 3026 e9935c2c4672
topic: add a 'enforce-all' mode The mode abort for all commit without a topic, even merges.
hgext3rd/topic/__init__.py
tests/test-topicmode.t
--- a/hgext3rd/topic/__init__.py	Sat Sep 30 23:18:29 2017 +0100
+++ b/hgext3rd/topic/__init__.py	Sun Oct 01 00:44:41 2017 +0100
@@ -60,6 +60,7 @@
     topic-mode = ignore # do nothing special (default)
     topic-mode = warning # print a warning
     topic-mode = enforce # abort the commit (except for merge)
+    topic-mode = enforce-all # abort the commit (even for merge)
 """
 
 from __future__ import absolute_import
@@ -891,6 +892,7 @@
     'ignore',
     'warning',
     'enforce',
+    'enforce-all',
 ]
 
 def _configtopicmode(ui):
@@ -918,6 +920,11 @@
         maywarn = (topicmode == "warning"
                    or (topicmode == "enforce" and ismergecommit))
 
+        if topicmode == 'enforce-all':
+            ismergecommit = False
+            mayabort = True
+            maywarn = False
+
         if opts.get('topic'):
             t = opts['topic']
             with repo.vfs.open('topic', 'w') as f:
--- a/tests/test-topicmode.t	Sat Sep 30 23:18:29 2017 +0100
+++ b/tests/test-topicmode.t	Sun Oct 01 00:44:41 2017 +0100
@@ -128,3 +128,60 @@
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     ROOT
   
+
+Testing the config knob to about on untopiced merge commit
+================================================================
+
+  $ hg init $TESTTMP/test-untopic-merge-commit-abort
+  $ cd $TESTTMP/test-untopic-merge-commit-abort
+  $ cat <<EOF >> .hg/hgrc
+  > [phases]
+  > publish=false
+  > EOF
+  $ cat <<EOF >> $HGRCPATH
+  > [experimental]
+  > topic-mode = enforce-all
+  > EOF
+  $ touch ROOT
+  $ hg commit -A -m "ROOT" --config experimental.topic-mode=off
+  adding ROOT
+  $ touch a
+  $ hg add a
+  $ hg topic mytopic
+  marked working directory as topic: mytopic
+  $ hg ci -m "Added a"
+  active topic 'mytopic' grew its first changeset
+
+  $ hg up -r "desc('ROOT')"
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ touch default
+  $ hg add default
+  $ hg commit -m "default" --config experimental.topic-mode=off
+
+  $ hg merge mytopic
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg commit -m "merge mytopic"
+  abort: no active topic
+  (set a current topic or use '--config experimental.topic-mode=off' to commit without a topic)
+  [255]
+
+  $ hg log -G
+  @  changeset:   2:a4da109ee59f
+  |  tag:         tip
+  |  parent:      0:ec1d2790416d
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     default
+  |
+  | @  changeset:   1:e5b6c632bd8e
+  |/   topic:       mytopic
+  |    user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    summary:     Added a
+  |
+  o  changeset:   0:ec1d2790416d
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     ROOT
+