comparison mercurial/hgweb/hgwebdir_mod.py @ 36907:c1de7efca574

hgweb: port to new response API These were the last consumers of wsgirequest.respond() \o/ Differential Revision: https://phab.mercurial-scm.org/D2829
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 11 Mar 2018 15:40:58 -0700
parents 6a0e4efbc61e
children cd6ae9ab7bd8
comparison
equal deleted inserted replaced
36906:6a0e4efbc61e 36907:c1de7efca574
13 13
14 from ..i18n import _ 14 from ..i18n import _
15 15
16 from .common import ( 16 from .common import (
17 ErrorResponse, 17 ErrorResponse,
18 HTTP_NOT_FOUND,
19 HTTP_SERVER_ERROR, 18 HTTP_SERVER_ERROR,
20 cspvalues, 19 cspvalues,
21 get_contact, 20 get_contact,
22 get_mtime, 21 get_mtime,
23 ismember, 22 ismember,
24 paritygen, 23 paritygen,
25 staticfile, 24 staticfile,
25 statusmessage,
26 ) 26 )
27 27
28 from .. import ( 28 from .. import (
29 configitems, 29 configitems,
30 encoding, 30 encoding,
31 error, 31 error,
32 hg, 32 hg,
33 profiling, 33 profiling,
34 pycompat,
34 scmutil, 35 scmutil,
35 templater, 36 templater,
36 ui as uimod, 37 ui as uimod,
37 util, 38 util,
38 ) 39 )
440 subdir = virtual + '/' 441 subdir = virtual + '/'
441 if [r for r in repos if r.startswith(subdir)]: 442 if [r for r in repos if r.startswith(subdir)]:
442 return self.makeindex(req, res, tmpl, subdir) 443 return self.makeindex(req, res, tmpl, subdir)
443 444
444 # prefixes not found 445 # prefixes not found
445 wsgireq.respond(HTTP_NOT_FOUND, ctype) 446 res.status = '404 Not Found'
446 return tmpl("notfound", repo=virtual) 447 res.setbodygen(tmpl('notfound', repo=virtual))
447 448 return res.sendresponse()
448 except ErrorResponse as err: 449
449 wsgireq.respond(err, ctype) 450 except ErrorResponse as e:
450 return tmpl('error', error=err.message or '') 451 res.status = statusmessage(e.code, pycompat.bytestr(e))
452 res.setbodygen(tmpl('error', error=e.message or ''))
453 return res.sendresponse()
451 finally: 454 finally:
452 tmpl = None 455 tmpl = None
453 456
454 def makeindex(self, req, res, tmpl, subdir=""): 457 def makeindex(self, req, res, tmpl, subdir=""):
455 self.refresh() 458 self.refresh()