hgext3rd/topic/__init__.py
changeset 5288 5cfec61b872b
parent 5276 8431bb224862
parent 5287 0cb07fb5d158
child 5299 426f2800b793
--- a/hgext3rd/topic/__init__.py	Tue Apr 07 19:33:40 2020 +0200
+++ b/hgext3rd/topic/__init__.py	Wed Apr 08 16:16:09 2020 +0200
@@ -374,7 +374,17 @@
     # Wrap changelog.add to drop empty topic
     extensions.wrapfunction(changelog.changelog, 'add', wrapadd)
     # Make exchange._checkpublish handle experimental.topic.publish-bare-branch
-    extensions.wrapfunction(exchange, '_checkpublish', flow.replacecheckpublish)
+    if util.safehasattr(exchange, '_checkpublish'):
+        extensions.wrapfunction(exchange, '_checkpublish',
+                                flow.replacecheckpublish)
+    else:
+        # hg <= 4.8 (33d30fb1e4ae)
+        try:
+            evolve = extensions.find(b'evolve')
+            extensions.wrapfunction(evolve.safeguard, '_checkpublish',
+                                    flow.replacecheckpublish)
+        except (KeyError, AttributeError):
+            pass
 
     server.setupserver(ui)