diff hgext3rd/topic/discovery.py @ 4123:119fced5a891 stable

topic: add a compatibility to access transaction's validator The attribute was made private in ebbba3ba3f66.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 21 Sep 2018 17:50:28 +0200
parents ca7f02c9fa57
children 49d442a2207f e527df0f2a68
line wrap: on
line diff
--- a/hgext3rd/topic/discovery.py	Fri Sep 21 11:58:42 2018 +0200
+++ b/hgext3rd/topic/discovery.py	Fri Sep 21 17:50:28 2018 +0200
@@ -153,7 +153,10 @@
         return
     tr._prepushheads = _nbheads(op.repo)
     reporef = weakref.ref(op.repo)
-    oldvalidator = tr.validator
+    if util.safehasattr(tr, 'validator'): # hg <= 4.7
+        oldvalidator = tr.validator
+    else:
+        oldvalidator = tr._validator
 
     def validator(tr):
         repo = reporef()
@@ -171,7 +174,10 @@
                             % branch)
                     raise error.Abort(msg)
         return oldvalidator(tr)
-    tr.validator = validator
+    if util.safehasattr(tr, 'validator'): # hg <= 4.7
+        tr.validator = validator
+    else:
+        tr._validator = validator
 handlecheckheads.params = frozenset()
 
 def _pushb2phases(orig, pushop, bundler):