changeset 882:48804a8d7472

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 12 Mar 2014 12:44:33 -0700
parents 380aa41a53a5
children d2fa1061df16
files hgext/simple4server.py tests/test-simple4server.t
diffstat 2 files changed, 51 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/simple4server.py	Mon Mar 10 19:47:24 2014 -0700
+++ b/hgext/simple4server.py	Wed Mar 12 12:44:33 2014 -0700
@@ -24,6 +24,21 @@
 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"""
@@ -231,3 +246,6 @@
         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)
--- a/tests/test-simple4server.t	Mon Mar 10 19:47:24 2014 -0700
+++ b/tests/test-simple4server.t	Wed Mar 12 12:44:33 2014 -0700
@@ -140,3 +140,36 @@
   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)