# HG changeset patch # User Pierre-Yves David # Date 1519380179 -3600 # Node ID 25155eb05f5f1657e325e7b77e3f190f72d25577 # Parent 5dc34b8571147af4f09123fd87d087e76cd9b36a legacy-push: fix the code forbidding legacy obsmarkers pulling changeset e69e65b2b4a9 in code remove a key try/except. We reintroduce it for compatibility. diff -r 5dc34b857114 -r 25155eb05f5f hgext3rd/evolve/obsexchange.py --- a/hgext3rd/evolve/obsexchange.py Wed Feb 21 17:45:50 2018 +0100 +++ b/hgext3rd/evolve/obsexchange.py Fri Feb 23 11:02:59 2018 +0100 @@ -25,6 +25,7 @@ pushkey, util, wireproto, + wireprotoserver, ) from mercurial.hgweb import common as hgwebcommon @@ -230,6 +231,26 @@ raise err return {} +# reinstall dispatch catching ResponseError as in hg 4.5 < +@eh.wrapfunction(wireprotoserver, 'parsehttprequest') +def parsehttprequest(orig, repo, req, query): + protohandler = orig(repo, req, query) + olddispatch = protohandler['dispatch'] + + def newdispatch(): + try: + return olddispatch() + except hgwebcommon.ErrorResponse as inst: + if protohandler['cmd'] != 'listkeys': + raise + req.headers.append((r'Connection', r'Close')) + req.respond(inst, wireprotoserver.HGTYPE, + body='0\n%s\n' % inst) + return '' + + protohandler['dispatch'] = newdispatch + return protohandler + @eh.uisetup def setuppushkeyforbidding(ui): pushkey._namespaces['obsolete'] = (forbidpushkey, forbidlistkey) diff -r 5dc34b857114 -r 25155eb05f5f tests/test-wireproto.t --- a/tests/test-wireproto.t Wed Feb 21 17:45:50 2018 +0100 +++ b/tests/test-wireproto.t Fri Feb 23 11:02:59 2018 +0100 @@ -202,6 +202,7 @@ $ hg debugpushkey http://localhost:$HGPORT/ obsolete abort: HTTP Error 410: won't exchange obsmarkers through pushkey [255] + $ cat errors.log $ 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)