diff hgext3rd/topic/__init__.py @ 6743:ab60707314e9 stable

topic: new experimental.tns-reject-push config to refuse changesets with tns
author Anton Shestakov <av6@dwimlabs.net>
date Fri, 15 Mar 2024 17:05:09 -0300
parents d959abd665fd
children 107c5af631a7
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Thu Mar 14 16:08:59 2024 -0300
+++ b/hgext3rd/topic/__init__.py	Fri Mar 15 17:05:09 2024 -0300
@@ -296,6 +296,9 @@
 configitem(b'experimental', b'tns-default-pull-namespaces',
            default=configitems.dynamicdefault,
 )
+configitem(b'experimental', b'tns-reject-push',
+           default=False,
+)
 configitem(b'experimental', b'topic-mode.server',
            default=configitems.dynamicdefault,
 )
@@ -914,6 +917,25 @@
                 else:
                     tr.addvalidator(b'000-reject-publish', _validate_publish)
 
+            if self.ui.configbool(b'experimental', b'tns-reject-push'):
+                if util.safehasattr(tr, '_validator'):
+                    # hg <= 5.3 (36f08ae87ef6)
+                    origvalidator_publish = tr._validator
+
+                def _validate_csets_with_tns(tr2):
+                    repo = reporef()
+                    flow.reject_csets_with_tns(repo, tr2)
+
+                def validator(tr2):
+                    _validate_csets_with_tns(tr2)
+                    return origvalidator_publish(tr2)
+
+                if util.safehasattr(tr, '_validator'):
+                    # hg <= 5.3 (36f08ae87ef6)
+                    tr._validator = validator
+                else:
+                    tr.addvalidator(b'000-reject-csets-with-tns', _validate_csets_with_tns)
+
             if util.safehasattr(tr, '_validator'):
                 # hg <= 5.3 (36f08ae87ef6)
                 origvalidator_affected_tns = tr._validator