evolve: handle wireproto module deletion for registering new commands
Module have been deleted in b4d85bc122bd. We can no longer import it blindly.
--- 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: