Mercurial > public > mercurial-scm > evolve
diff hgext3rd/topic/__init__.py @ 4647:228caeb8b7af
topic: add a simple option to reject publishing
The option is pretty basic but it can be used as base to build larger feature.
The main target for going in this direction is to be able to distinct between
user that are "simple contributors" pushing topic for review and the
"maintainers" or "automation" that can publish changesets.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 27 May 2019 03:42:35 +0200 |
parents | 7b986968700b |
children | b72cd597a887 |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Tue Jun 04 10:07:08 2019 +0200 +++ b/hgext3rd/topic/__init__.py Mon May 27 03:42:35 2019 +0200 @@ -104,6 +104,12 @@ In addition, the topic extension adds a ``--publish`` flag on :hg:`push`. When used, the pushed revisions are published if the push succeeds. It also applies to common revisions selected by the push. + +One can prevent any publishing to happens in a repository using:: + + [experimental] + topic.allow-publish = no + """ from __future__ import absolute_import @@ -205,6 +211,9 @@ configitem('experimental', 'topic.publish-bare-branch', default=False, ) + configitem('experimental', 'topic.allow-publish', + default=configitems.dynamicdefault, + ) configitem('_internal', 'keep-topic', default=False, ) @@ -496,6 +505,23 @@ flow.publishbarebranch(repo, tr2) origclose() tr.close = close + allow_publish = self.ui.configbool('experimental', + 'topic.allow-publish', + True) + if not allow_publish: + if util.safehasattr(tr, 'validator'): # hg <= 4.7 + origvalidator = tr.validator + else: + origvalidator = tr._validator + + def validator(tr2): + repo = reporef() + flow.reject_publish(repo, tr2) + return origvalidator(tr2) + if util.safehasattr(tr, 'validator'): # hg <= 4.7 + tr.validator = validator + else: + tr._validator = validator # real transaction start ct = self.currenttopic