Mercurial > evolve
changeset 3175:00b003ebb873
branching: merge stable into default
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 07 Nov 2017 13:04:58 +0100 |
parents | 007e4d294ebe (current diff) d56b8f5f0bb1 (diff) |
children | 85ab7d2d9fd6 |
files | |
diffstat | 4 files changed, 56 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGELOG Thu Nov 02 00:48:25 2017 +0100 +++ b/CHANGELOG Tue Nov 07 13:04:58 2017 +0100 @@ -1,6 +1,16 @@ Changelog ========= +7.0.1 - in progress +------------------- + + * obsdiscovery: allow the config option to disable discovery server side + (it was previously only honored on the client side) + + * server: avoid exposing 'abort' to evolution enabled client talking + to server with the extension bu obsolescence marker exchange + disabled. + 7.0.0 -- 2017-10-23 -------------------
--- a/hgext3rd/evolve/obsdiscovery.py Thu Nov 02 00:48:25 2017 +0100 +++ b/hgext3rd/evolve/obsdiscovery.py Tue Nov 07 13:04:58 2017 +0100 @@ -820,7 +820,8 @@ def _obshash_capabilities(orig, repo, proto): """wrapper to advertise new capability""" caps = orig(repo, proto) - if obsolete.isenabled(repo, obsolete.exchangeopt): + if (obsolete.isenabled(repo, obsolete.exchangeopt) + and repo.ui.configbool('experimental', 'evolution.obsdiscovery', True)): caps = caps.split() caps.append('_evoext_obshash_0') caps.append('_evoext_obshash_1')
--- a/hgext3rd/evolve/obsexchange.py Thu Nov 02 00:48:25 2017 +0100 +++ b/hgext3rd/evolve/obsexchange.py Tue Nov 07 13:04:58 2017 +0100 @@ -27,6 +27,8 @@ wireproto, ) +from mercurial.hgweb import common as hgwebcommon + from . import ( exthelper, utility, @@ -197,10 +199,25 @@ abortmsg = "won't exchange obsmarkers through pushkey" hint = "upgrade your client or server to use the bundle2 protocol" +class HTTPCompatibleAbort(hgwebcommon.ErrorResponse, error.Abort): + def __init__(self, message, code, hint=None): + # initialisation of each class is a bit messy. + # We explicitly do the dispatch + hgwebcommon.ErrorResponse.__init__(self, 410, message) + error.Abort.__init__(self, message, hint=hint) + def forbidpushkey(repo=None, key=None, old=None, new=None): """prevent exchange through pushkey""" - raise error.Abort(abortmsg, hint=hint) + err = HTTPCompatibleAbort(abortmsg, 410, hint=hint) + raise err + +def forbidlistkey(repo=None, key=None, old=None, new=None): + """prevent exchange through pushkey""" + if obsolete.isenabled(repo, obsolete.exchangeopt): + err = HTTPCompatibleAbort(abortmsg, 410, hint=hint) + raise err + return {} @eh.uisetup def setuppushkeyforbidding(ui): - pushkey._namespaces['obsolete'] = (forbidpushkey, forbidpushkey) + pushkey._namespaces['obsolete'] = (forbidpushkey, forbidlistkey)
--- a/tests/test-wireproto.t Thu Nov 02 00:48:25 2017 +0100 +++ b/tests/test-wireproto.t Tue Nov 07 13:04:58 2017 +0100 @@ -188,3 +188,28 @@ obsmarker-exchange: 258 bytes received $ cd .. + +And disable it server side too: + + $ hg serve -R server -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log --config experimental.evolution.obsdiscovery=no + $ cat hg.pid >> $DAEMON_PIDS + + $ curl -s http://localhost:$HGPORT/?cmd=capabilities + _evoext_getbundle_obscommon batch branchmap bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aobsmarkers%3DV0%2CV1%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps changegroupsubset compression=zstd,zlib getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (no-eol) + +Check we cannot use pushkey for marker exchange anymore + + $ hg debugpushkey http://localhost:$HGPORT/ obsolete + abort: HTTP Error 410: won't exchange obsmarkers through pushkey + [255] + $ hg debugpushkey ssh://user@dummy/server obsolete + remote: abort: won't exchange obsmarkers through pushkey + remote: (upgrade your client or server to use the bundle2 protocol) + abort: unexpected response: empty string + [255] + +But we do let it goes fine on repository with exchange disabled: + + $ $RUNTESTDIR/killdaemons.py $DAEMON_PIDS + $ hg serve -R server -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log --config experimental.evolution='!' + $ hg debugpushkey http://localhost:$HGPORT/ obsolete