# HG changeset patch # User Pierre-Yves David # Date 1394653473 25200 # Node ID 48804a8d7472dcac8c2bce10307f4f5c8f524be0 # Parent 380aa41a53a57c84ac788eb82923046eaca7da53 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. diff -r 380aa41a53a5 -r 48804a8d7472 hgext/simple4server.py --- 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) diff -r 380aa41a53a5 -r 48804a8d7472 tests/test-simple4server.t --- 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)