changeset 3680:e2a91d4d207d

evolve: handle wireproto module deletion for registering new commands Module have been deleted in b4d85bc122bd. We can no longer import it blindly.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 19 Apr 2018 10:55:57 +0200
parents b12c5d107187
children 3f90e6c5d140
files hgext3rd/evolve/compat.py
diffstat 1 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/compat.py	Thu Apr 19 10:53:59 2018 +0200
+++ b/hgext3rd/evolve/compat.py	Thu Apr 19 10:55:57 2018 +0200
@@ -18,7 +18,6 @@
     obsolete,
     revset,
     util,
-    wireproto,
 )
 from mercurial.hgweb import hgweb_mod
 
@@ -284,17 +283,23 @@
     parsedate = mercurial.util.parsedate
 
 def wireprotocommand(exthelper, name, args='', permission='pull'):
+    try:
+        # Since b4d85bc1
+        from mercurial.wireprotov1server import wireprotocommand
+        return wireprotocommand(name, args, permission=permission)
+    except (ImportError, AttributeError):
+        from mercurial import wireproto
+
     if 3 <= len(wireproto.wireprotocommand.func_defaults):
         return wireproto.wireprotocommand(name, args, permission=permission)
 
-    else:
-        # <= hg-4.5 permission must be registered in dictionnary
-        def decorator(func):
-            @eh.extsetup
-            def install(ui):
-                hgweb_mod.perms[name] = permission
-                wireproto.commands[name] = (func, args)
-        return decorator
+    # <= hg-4.5 permission must be registered in dictionnary
+    def decorator(func):
+        @eh.extsetup
+        def install(ui):
+            hgweb_mod.perms[name] = permission
+            wireproto.commands[name] = (func, args)
+    return decorator
 
 # mercurial <= 4.5 do not have the updateresult object
 try: