diff hgext3rd/topic/__init__.py @ 6700:a7d94f235488

topic: remove transaction validator compatibility for hg 5.3
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 26 Oct 2023 14:49:37 -0300
parents e0712a00154e
children f0cbc19e77ef
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Wed Feb 07 16:31:44 2024 -0300
+++ b/hgext3rd/topic/__init__.py	Thu Oct 26 14:49:37 2023 -0300
@@ -843,23 +843,11 @@
 
             reporef = weakref.ref(self)
             if self.ui.configbool(b'experimental', b'enforce-single-head'):
-                if util.safehasattr(tr, '_validator'):
-                    # hg <= 5.3 (36f08ae87ef6)
-                    origvalidator_single_head = tr._validator
-
                 def _validate_single_head(tr2):
                     repo = reporef()
                     flow.enforcesinglehead(repo, tr2)
 
-                def validator(tr2):
-                    _validate_single_head(tr2)
-                    return origvalidator_single_head(tr2)
-
-                if util.safehasattr(tr, '_validator'):
-                    # hg <= 5.3 (36f08ae87ef6)
-                    tr._validator = validator
-                else:
-                    tr.addvalidator(b'000-enforce-single-head', _validate_single_head)
+                tr.addvalidator(b'000-enforce-single-head', _validate_single_head)
 
             topicmodeserver = self.ui.config(b'experimental',
                                              b'topic-mode.server', b'ignore')
@@ -867,23 +855,11 @@
                                              b'topic.publish-bare-branch')
             ispush = desc.startswith((b'push', b'serve'))
             if (topicmodeserver != b'ignore' and ispush):
-                if util.safehasattr(tr, '_validator'):
-                    # hg <= 5.3 (36f08ae87ef6)
-                    origvalidator_untopiced = tr._validator
-
                 def _validate_untopiced(tr2):
                     repo = reporef()
                     flow.rejectuntopicedchangeset(repo, tr2)
 
-                def validator(tr2):
-                    _validate_untopiced(tr2)
-                    return origvalidator_untopiced(tr2)
-
-                if util.safehasattr(tr, '_validator'):
-                    # hg <= 5.3 (36f08ae87ef6)
-                    tr._validator = validator
-                else:
-                    tr.addvalidator(b'000-reject-untopiced', _validate_untopiced)
+                tr.addvalidator(b'000-reject-untopiced', _validate_untopiced)
 
             elif publishbare and ispush:
                 origclose = tr.close
@@ -899,43 +875,18 @@
                                                b'topic.allow-publish',
                                                True)
             if not allow_publish:
-                if util.safehasattr(tr, '_validator'):
-                    # hg <= 5.3 (36f08ae87ef6)
-                    origvalidator_publish = tr._validator
-
                 def _validate_publish(tr2):
                     repo = reporef()
                     flow.reject_publish(repo, tr2)
 
-                def validator(tr2):
-                    _validate_publish(tr2)
-                    return origvalidator_publish(tr2)
-
-                if util.safehasattr(tr, '_validator'):
-                    # hg <= 5.3 (36f08ae87ef6)
-                    tr._validator = validator
-                else:
-                    tr.addvalidator(b'000-reject-publish', _validate_publish)
-
-            if util.safehasattr(tr, '_validator'):
-                # hg <= 5.3 (36f08ae87ef6)
-                origvalidator_affected_tns = tr._validator
+                tr.addvalidator(b'000-reject-publish', _validate_publish)
 
             def _validate_affected_tns(tr2):
                 repo = reporef()
                 assert repo is not None  # help pytype
                 find_affected_tns(repo, tr2)
 
-            def validator(tr2):
-                result = origvalidator_affected_tns(tr2)
-                _validate_affected_tns(tr2)
-                return result
-
-            if util.safehasattr(tr, '_validator'):
-                # hg <= 5.3 (36f08ae87ef6)
-                tr._validator = validator
-            else:
-                tr.addvalidator(b'999-find-affected-tns', _validate_affected_tns)
+            tr.addvalidator(b'999-find-affected-tns', _validate_affected_tns)
 
             # real transaction start
             ct = self.currenttopic