discovery: handle deletion of 'wireproto' module
Mercurial commit b4d85bc122bd. deleted the wireproto module and its
contents are now in various other modules, so we can not even do
unchecked imports of it now.
--- a/hgext3rd/evolve/obsdiscovery.py Thu Apr 19 10:55:57 2018 +0200
+++ b/hgext3rd/evolve/obsdiscovery.py Thu Apr 19 10:59:12 2018 +0200
@@ -42,7 +42,6 @@
scmutil,
setdiscovery,
util,
- wireproto,
)
from mercurial.i18n import _
@@ -56,8 +55,11 @@
)
try: # < hg-4.6
+ from mercurial import wireproto as wireprototypes
+ wireprotov1server = wireprototypes
from mercurial.wireproto import wirepeer, encodelist, decodelist
-except ImportError:
+except (ImportError, AttributeError):
+ from mercurial import wireprototypes, wireprotov1server
from mercurial.wireprotov1peer import wirepeer
from mercurial.wireprototypes import encodelist, decodelist
@@ -722,20 +724,20 @@
# Compat hg 4.6+ (2f7290555c96)
if bytesresponse:
- from mercurial import wireprototypes
caps = wireprototypes.bytesresponse(caps)
return caps
@eh.extsetup
def obshashrange_extsetup(ui):
###
- extensions.wrapfunction(wireproto, 'capabilities', _obshashrange_capabilities)
+ extensions.wrapfunction(wireprotov1server, 'capabilities',
+ _obshashrange_capabilities)
# wrap command content
- oldcap, args = wireproto.commands['capabilities']
+ oldcap, args = wireprotov1server.commands['capabilities']
def newcap(repo, proto):
return _obshashrange_capabilities(oldcap, repo, proto)
- wireproto.commands['capabilities'] = (newcap, args)
+ wireprotov1server.commands['capabilities'] = (newcap, args)
#############################
### Tree Hash computation ###
@@ -878,19 +880,19 @@
# Compat hg 4.6+ (2f7290555c96)
if bytesresponse:
- from mercurial import wireprototypes
caps = wireprototypes.bytesresponse(caps)
return caps
@eh.extsetup
def obshash_extsetup(ui):
- extensions.wrapfunction(wireproto, 'capabilities', _obshash_capabilities)
+ extensions.wrapfunction(wireprotov1server, 'capabilities',
+ _obshash_capabilities)
# wrap command content
- oldcap, args = wireproto.commands['capabilities']
+ oldcap, args = wireprotov1server.commands['capabilities']
def newcap(repo, proto):
return _obshash_capabilities(oldcap, repo, proto)
- wireproto.commands['capabilities'] = (newcap, args)
+ wireprotov1server.commands['capabilities'] = (newcap, args)
##########################################
### trigger discovery during exchange ###