comparison mercurial/hgweb/webcommands.py @ 45398:dc9fe90bdbd5

hgweb: let staticfile() look up path from default location unless provided This reduces duplication between the two callers. Differential Revision: https://phab.mercurial-scm.org/D8934
author Martin von Zweigbergk <martinvonz@google.com>
date Sat, 22 Aug 2020 16:03:44 -0700
parents da3b7c80aa34
children 914ca0a98518
comparison
equal deleted inserted replaced
45397:da3b7c80aa34 45398:dc9fe90bdbd5
34 pycompat, 34 pycompat,
35 revset, 35 revset,
36 revsetlang, 36 revsetlang,
37 scmutil, 37 scmutil,
38 smartset, 38 smartset,
39 templater,
40 templateutil, 39 templateutil,
41 ) 40 )
42 41
43 from ..utils import stringutil 42 from ..utils import stringutil
44 43
1316 def static(web): 1315 def static(web):
1317 fname = web.req.qsparams[b'file'] 1316 fname = web.req.qsparams[b'file']
1318 # a repo owner may set web.static in .hg/hgrc to get any file 1317 # a repo owner may set web.static in .hg/hgrc to get any file
1319 # readable by the user running the CGI script 1318 # readable by the user running the CGI script
1320 static = web.config(b"web", b"static", untrusted=False) 1319 static = web.config(b"web", b"static", untrusted=False)
1321 if not static: 1320 staticfile(web.templatepath, static, fname, web.res)
1322 tp = web.templatepath or templater.templatedir()
1323 if tp is not None:
1324 static = os.path.join(tp, b'static')
1325
1326 staticfile(static, fname, web.res)
1327 return web.res.sendresponse() 1321 return web.res.sendresponse()
1328 1322
1329 1323
1330 @webcommand(b'graph') 1324 @webcommand(b'graph')
1331 def graph(web): 1325 def graph(web):