Mercurial > public > mercurial-scm > evolve
diff hgext3rd/topic/__init__.py @ 3024:89855920fb0f
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.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Sat, 30 Sep 2017 23:18:29 +0100 |
parents | cc740c545776 |
children | e814c553ef32 |
line wrap: on
line diff
--- 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)