# HG changeset patch # User Pierre-Yves David # Date 1506815081 -3600 # Node ID e814c553ef3219cf5e2113b74f736b66f5d7d50c # Parent 89855920fb0fcd5fb6e2615bcdc36bc7ab120b9a topic: add a 'enforce-all' mode The mode abort for all commit without a topic, even merges. diff -r 89855920fb0f -r e814c553ef32 hgext3rd/topic/__init__.py --- 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: diff -r 89855920fb0f -r e814c553ef32 tests/test-topicmode.t --- 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 <> .hg/hgrc + > [phases] + > publish=false + > EOF + $ cat <> $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 +