Mercurial > evolve
diff hgext3rd/topic/flow.py @ 3235:8a772f0c54d9
topics: add a config to reject draft changeset without topic on a server
This patch adds a new config option experimental.topic-mode.server which if
sets to True, the server won't accept any draft changeset without topic on it.
In case both `experimental.topic-mode.server` and
`experimental.topic.publish-bare-branch` are set to True, the enforce-topic one
is respected.
Tests are added for it. The CHANGELOG file is also updated mentioning about the
config option.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sat, 09 Dec 2017 06:13:28 +0100 |
parents | 5dfe4e5cf9e4 |
children | 3675fe74521d |
line wrap: on
line diff
--- a/hgext3rd/topic/flow.py Sat Dec 09 05:05:39 2017 +0100 +++ b/hgext3rd/topic/flow.py Sat Dec 09 06:13:28 2017 +0100 @@ -30,6 +30,31 @@ nodes = [cl.node(r) for r in topublish] repo._phasecache.advanceboundary(repo, tr, phases.public, nodes) +def rejectuntopicedchangeset(repo, tr): + """Reject the push if there are changeset without topic""" + if not tr.changes['revs']: # no new revs + return + + mode = repo.ui.config('experimental', 'topic-mode.server', 'ignore') + + revs = list(tr.changes['revs']) + untopiced = repo.revs('not public() and (%ld:) - hidden() - topic()', revs) + if untopiced: + num = len(untopiced) + fnode = repo[untopiced.first()].hex()[:10] + if num == 1: + msg = _("%s") % fnode + else: + msg = _("%s and %d more") % (fnode, num - 1) + if mode == 'warning': + fullmsg = _("pushed draft changeset without topic: %s\n") + repo.ui.warn(fullmsg % msg) + elif mode == 'enforce': + fullmsg = _("rejecting draft changesets: %s") + raise error.Abort(fullmsg % msg) + else: + repo.ui.warn(_("unknown 'topic-mode.server': %s\n" % mode)) + def wrappush(orig, repo, remote, *args, **kwargs): """interpret the --publish flag and pass it to the push operation""" newargs = kwargs.copy()