Commits

Anonymous committed 48804a8

simple4server: option to advertise obsolescence support

We had an option to control the advertising of the obsolescence markers support
from the server. The goal of this option is to allow large scale repo hosting
service to control the use of obsolescence markers exchange.

Comments (0)

Files changed (2)

hgext/simple4server.py

 from mercurial.hgweb import hgweb_mod
 _pack = struct.pack
 
+# Start of simple4server specific content
+
+from mercurial import pushkey
+
+# specific content also include the wrapping int extsetup
+def _nslist(orig, repo):
+    rep = orig(repo)
+    if not repo.ui.configbool('__temporary__', 'advertiseobsolete', True):
+        rep.pop('obsolete')
+    return rep
+
+# End of simple4server specific content
+
+
+
 # from evolve extension: 1a23c7c52a43
 def srv_pushobsmarkers(repo, proto):
     """That receives a stream of markers and apply then to the repo"""
         return capabilities(oldcap, repo, proto)
     wireproto.commands['capabilities'] = (newcap, args)
     wireproto.commands['evoext_obshash'] = (srv_obshash, 'nodes')
+    # specific simple4server content
+    extensions.wrapfunction(pushkey, '_nslist', _nslist)
+    pushkey._namespaces['namespaces'] = (lambda *x: False, pushkey._nslist)

tests/test-simple4server.t

   OBSEXC: no unknown remote markers
   OBSEXC: DONE
 
+  $ cd ..
+
+Test disabling obsolete advertisement
+===========================================
+(used by bitbucket to select which repo use evolve)
+
+  $ curl --silent "http://localhost:$HGPORT/?cmd=listkeys&namespace=namespaces"
+  bookmarks	
+  phases	
+  namespaces	
+  obsolete	 (no-eol)
+
+  $ echo '[__temporary__]' >> server/.hg/hgrc
+  $ echo 'advertiseobsolete=False' >> server/.hg/hgrc
+  $ $TESTDIR/killdaemons.py
+  $ hg serve -R server -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
+  $ cat hg.pid >> $DAEMON_PIDS
+
+  $ curl --silent "http://localhost:$HGPORT/?cmd=listkeys&namespace=namespaces"
+  bookmarks	
+  phases	
+  namespaces	 (no-eol)
+
+  $ echo 'advertiseobsolete=True' >> server/.hg/hgrc
+  $ $TESTDIR/killdaemons.py
+  $ hg serve -R server -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
+  $ cat hg.pid >> $DAEMON_PIDS
+
+  $ curl --silent "http://localhost:$HGPORT/?cmd=listkeys&namespace=namespaces"
+  bookmarks	
+  phases	
+  namespaces	
+  obsolete	 (no-eol)