discovery: use a different setup step for discovery
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 27 Aug 2014 12:05:49 +0200
changeset 1075 1205f42ae54c
parent 1074 442ab25f4747
child 1076 2039385d6460
discovery: use a different setup step for discovery This will ease the dropping of the other part later.
hgext/evolve.py
--- a/hgext/evolve.py	Wed Aug 27 12:04:57 2014 +0200
+++ b/hgext/evolve.py	Wed Aug 27 12:05:49 2014 +0200
@@ -2227,7 +2227,23 @@
     ui.progress(topic, *args, **kwargs)
 
 
+@eh.wrapfunction(wireproto, 'capabilities')
+def discocapabilities(orig, repo, proto):
+    """wrapper to advertise new capability"""
+    caps = orig(repo, proto)
+    if obsolete._enabled:
+        caps += ' _evoext_obshash_0'
+    return caps
 
+@eh.extsetup
+def _installobsmarkersdiscovery(ui):
+    hgweb_mod.perms['evoext_obshash'] = 'pull'
+    # wrap command content
+    oldcap, args = wireproto.commands['capabilities']
+    def newcap(repo, proto):
+        return discocapabilities(oldcap, repo, proto)
+    wireproto.commands['capabilities'] = (newcap, args)
+    wireproto.commands['evoext_obshash'] = (srv_obshash, 'nodes')
 
 ### Set discovery START
 
@@ -2766,7 +2782,6 @@
     localrepo.moderncaps.add('_evoext_b2x_obsmarkers_0')
     hgweb_mod.perms['evoext_pushobsmarkers_0'] = 'push'
     hgweb_mod.perms['evoext_pullobsmarkers_0'] = 'pull'
-    hgweb_mod.perms['evoext_obshash'] = 'pull'
     wireproto.commands['evoext_pushobsmarkers_0'] = (srv_pushobsmarkers, '')
     wireproto.commands['evoext_pullobsmarkers_0'] = (srv_pullobsmarkers, '*')
     # wrap command content
@@ -2774,4 +2789,3 @@
     def newcap(repo, proto):
         return capabilities(oldcap, repo, proto)
     wireproto.commands['capabilities'] = (newcap, args)
-    wireproto.commands['evoext_obshash'] = (srv_obshash, 'nodes')