wireproto: fix *_capabilities for change of API types
authorBoris Feld <boris.feld@octobus.net>
Wed, 14 Feb 2018 14:53:43 +0100
changeset 3500 a43fdbd6f7eb
parent 3499 512706514555
child 3501 7c8150697810
wireproto: fix *_capabilities for change of API types Mercurial commit 2f7290555c96 introduced new types for *_capabilities, update the code to use them.
hgext3rd/evolve/obsdiscovery.py
hgext3rd/evolve/obsexchange.py
--- a/hgext3rd/evolve/obsdiscovery.py	Wed Feb 14 09:46:56 2018 +0100
+++ b/hgext3rd/evolve/obsdiscovery.py	Wed Feb 14 14:53:43 2018 +0100
@@ -698,10 +698,22 @@
     caps = orig(repo, proto)
     enabled = _useobshashrange(repo)
     if obsolete.isenabled(repo, obsolete.exchangeopt) and enabled:
+
+        # Compat hg 4.6+ (2f7290555c96)
+        bytesresponse = False
+        if util.safehasattr(caps, 'data'):
+            bytesresponse = True
+            caps = caps.data
+
         caps = caps.split()
-        caps.append('_evoext_obshashrange_v1')
+        caps.append(b'_evoext_obshashrange_v1')
         caps.sort()
-        caps = ' '.join(caps)
+        caps = b' '.join(caps)
+
+        # Compat hg 4.6+ (2f7290555c96)
+        if bytesresponse:
+            from mercurial import wireprototypes
+            caps = wireprototypes.bytesresponse(caps)
     return caps
 
 @eh.extsetup
@@ -840,11 +852,23 @@
     caps = orig(repo, proto)
     if (obsolete.isenabled(repo, obsolete.exchangeopt)
         and repo.ui.configbool('experimental', 'evolution.obsdiscovery', True)):
+
+        # Compat hg 4.6+ (2f7290555c96)
+        bytesresponse = False
+        if util.safehasattr(caps, 'data'):
+            bytesresponse = True
+            caps = caps.data
+
         caps = caps.split()
-        caps.append('_evoext_obshash_0')
-        caps.append('_evoext_obshash_1')
+        caps.append(b'_evoext_obshash_0')
+        caps.append(b'_evoext_obshash_1')
         caps.sort()
-        caps = ' '.join(caps)
+        caps = b' '.join(caps)
+
+        # Compat hg 4.6+ (2f7290555c96)
+        if bytesresponse:
+            from mercurial import wireprototypes
+            caps = wireprototypes.bytesresponse(caps)
     return caps
 
 @eh.extsetup
--- a/hgext3rd/evolve/obsexchange.py	Wed Feb 14 09:46:56 2018 +0100
+++ b/hgext3rd/evolve/obsexchange.py	Wed Feb 14 14:53:43 2018 +0100
@@ -106,10 +106,22 @@
     """wrapper to advertise new capability"""
     caps = orig(repo, proto)
     if obsolete.isenabled(repo, obsolete.exchangeopt):
+
+        # Compat hg 4.6+ (2f7290555c96)
+        bytesresponse = False
+        if util.safehasattr(caps, 'data'):
+            bytesresponse = True
+            caps = caps.data
+
         caps = caps.split()
-        caps.append('_evoext_getbundle_obscommon')
+        caps.append(b'_evoext_getbundle_obscommon')
         caps.sort()
-        caps = ' '.join(caps)
+        caps = b' '.join(caps)
+
+        # Compat hg 4.6+ (2f7290555c96)
+        if bytesresponse:
+            from mercurial import wireprototypes
+            caps = wireprototypes.bytesresponse(caps)
     return caps
 
 @eh.extsetup