changeset 3681:3f90e6c5d140

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 19 Apr 2018 10:59:12 +0200
parents e2a91d4d207d
children 72f61b9cb8e9
files hgext3rd/evolve/obsdiscovery.py
diffstat 1 files changed, 12 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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 ###