comparison 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
comparison
equal deleted inserted replaced
30913:d70971a3ae80 30914:f3807a135e43
837 if proto.name == 'http': 837 if proto.name == 'http':
838 return ooberror(bundle2required) 838 return ooberror(bundle2required)
839 raise error.Abort(bundle2requiredmain, 839 raise error.Abort(bundle2requiredmain,
840 hint=bundle2requiredhint) 840 hint=bundle2requiredhint)
841 841
842 chunks = exchange.getbundlechunks(repo, 'serve', **opts) 842 #chunks = exchange.getbundlechunks(repo, 'serve', **opts)
843 try:
844 chunks = exchange.getbundlechunks(repo, 'serve', **opts)
845 except error.Abort as exc:
846 # cleanly forward Abort error to the client
847 if not exchange.bundle2requested(opts.get('bundlecaps')):
848 if proto.name == 'http':
849 return ooberror(str(exc) + '\n')
850 raise # cannot do better for bundle1 + ssh
851 # bundle2 request expect a bundle2 reply
852 bundler = bundle2.bundle20(repo.ui)
853 manargs = [('message', str(exc))]
854 advargs = []
855 if exc.hint is not None:
856 advargs.append(('hint', exc.hint))
857 bundler.addpart(bundle2.bundlepart('error:abort',
858 manargs, advargs))
859 return streamres(gen=bundler.getchunks(), v1compressible=True)
843 return streamres(gen=chunks, v1compressible=True) 860 return streamres(gen=chunks, v1compressible=True)
844 861
845 @wireprotocommand('heads') 862 @wireprotocommand('heads')
846 def heads(repo, proto): 863 def heads(repo, proto):
847 h = repo.heads() 864 h = repo.heads()