# HG changeset patch # User Pierre-Yves David # Date 1524128352 -7200 # Node ID 3f90e6c5d140eb429232eb1418c741704a3fe986 # Parent e2a91d4d207d0407686274fa859b9ff8d81acd4e 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. diff -r e2a91d4d207d -r 3f90e6c5d140 hgext3rd/evolve/obsdiscovery.py --- 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 ###