--- 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