Mercurial > hg
diff mercurial/wireproto.py @ 30914:f3807a135e43 stable
wireproto: properly report server Abort during 'getbundle'
Previously Abort raised during 'getbundle' call poorly reported (HTTP-500 for
http, some scary messages for ssh). Abort error have been properly reported for
"push" for a long time, there is not reason to be different for 'getbundle'. We
properly catch such error and report them back the best way available. For
bundle, we issue a valid bundle2 reply (as expected by the client) with an
'error:abort' part. With bundle1 we do as best as we can depending of http or
ssh.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Fri, 10 Feb 2017 18:20:58 +0100 |
parents | 3d4afc2fdcd7 |
children | 48dea083f66d |
line wrap: on
line diff
--- a/mercurial/wireproto.py Fri Feb 10 18:17:20 2017 +0100 +++ b/mercurial/wireproto.py Fri Feb 10 18:20:58 2017 +0100 @@ -839,7 +839,24 @@ raise error.Abort(bundle2requiredmain, hint=bundle2requiredhint) - chunks = exchange.getbundlechunks(repo, 'serve', **opts) + #chunks = exchange.getbundlechunks(repo, 'serve', **opts) + try: + chunks = exchange.getbundlechunks(repo, 'serve', **opts) + except error.Abort as exc: + # cleanly forward Abort error to the client + if not exchange.bundle2requested(opts.get('bundlecaps')): + if proto.name == 'http': + return ooberror(str(exc) + '\n') + raise # cannot do better for bundle1 + ssh + # bundle2 request expect a bundle2 reply + bundler = bundle2.bundle20(repo.ui) + manargs = [('message', str(exc))] + advargs = [] + if exc.hint is not None: + advargs.append(('hint', exc.hint)) + bundler.addpart(bundle2.bundlepart('error:abort', + manargs, advargs)) + return streamres(gen=bundler.getchunks(), v1compressible=True) return streamres(gen=chunks, v1compressible=True) @wireprotocommand('heads')