# HG changeset patch # User Boris Feld # Date 1506809909 -3600 # Node ID 89855920fb0fcd5fb6e2615bcdc36bc7ab120b9a # Parent cc740c545776dc9c7748f4d2afe8d43ff8eb9d86 topicmode: 'enforce' topic mode, no longer warn about untopiced merge merging a topic back in a branch is common case, it seems sensible to not pester the user about it. diff -r cc740c545776 -r 89855920fb0f hgext3rd/topic/__init__.py --- 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) diff -r cc740c545776 -r 89855920fb0f tests/test-topicmode.t --- a/tests/test-topicmode.t Sat Sep 30 23:00:21 2017 +0100 +++ b/tests/test-topicmode.t Sat Sep 30 23:18:29 2017 +0100 @@ -66,3 +66,65 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: added a' + +Testing the new config knob to warn about untopiced merge commit +================================================================ + + $ hg init $TESTTMP/test-untopic-merge-commit + $ cd $TESTTMP/test-untopic-merge-commit + $ cat <> .hg/hgrc + > [phases] + > publish=false + > EOF + $ cat <> $HGRCPATH + > [experimental] + > topic-mode = enforce + > 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" + warning: new draft commit without topic + + $ hg log -G + @ changeset: 3:676a445d1c09 + |\ tag: tip + | | parent: 2:a4da109ee59f + | | parent: 1:e5b6c632bd8e + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: merge mytopic + | | + | o changeset: 2:a4da109ee59f + | | parent: 0:ec1d2790416d + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: default + | | + o | 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 +