Mercurial > evolve
changeset 3173:3afe20410b55 stable
wireproto: gracefully fail on http when trying to use older pushkey method
Previously the HTTP server would return a 500. It now returns a 410.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 07 Nov 2017 12:36:27 +0100 |
parents | aed2cac9edc3 |
children | d56b8f5f0bb1 |
files | hgext3rd/evolve/obsexchange.py tests/test-wireproto.t |
diffstat | 2 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/obsexchange.py Tue Nov 07 12:10:22 2017 +0100 +++ b/hgext3rd/evolve/obsexchange.py Tue Nov 07 12:36:27 2017 +0100 @@ -27,6 +27,8 @@ wireproto, ) +from mercurial.hgweb import common as hgwebcommon + from . import ( exthelper, utility, @@ -197,14 +199,23 @@ 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): - raise error.Abort(abortmsg, hint=hint) + err = HTTPCompatibleAbort(abortmsg, 410, hint=hint) + raise err return {} @eh.uisetup
--- a/tests/test-wireproto.t Tue Nov 07 12:10:22 2017 +0100 +++ b/tests/test-wireproto.t Tue Nov 07 12:36:27 2017 +0100 @@ -200,7 +200,7 @@ Check we cannot use pushkey for marker exchange anymore $ hg debugpushkey http://localhost:$HGPORT/ obsolete - abort: HTTP Error 500: Internal Server Error + 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