Also make it work on Python 3.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Also make it work on Python 3.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
from .request import wsgirequest | from .request import wsgirequest | ||||
from .. import ( | from .. import ( | ||||
encoding, | encoding, | ||||
error, | error, | ||||
hg, | hg, | ||||
hook, | hook, | ||||
profiling, | profiling, | ||||
pycompat, | |||||
repoview, | repoview, | ||||
templatefilters, | templatefilters, | ||||
templater, | templater, | ||||
ui as uimod, | ui as uimod, | ||||
util, | util, | ||||
) | ) | ||||
from . import ( | from . import ( | ||||
} | } | ||||
archivespecs = util.sortdict(( | archivespecs = util.sortdict(( | ||||
('zip', ('application/zip', 'zip', '.zip', None)), | ('zip', ('application/zip', 'zip', '.zip', None)), | ||||
('gz', ('application/x-gzip', 'tgz', '.tar.gz', None)), | ('gz', ('application/x-gzip', 'tgz', '.tar.gz', None)), | ||||
('bz2', ('application/x-bzip2', 'tbz2', '.tar.bz2', None)), | ('bz2', ('application/x-bzip2', 'tbz2', '.tar.bz2', None)), | ||||
)) | )) | ||||
def getstyle(req, configfn, templatepath): | |||||
fromreq = req.form.get('style', [None])[0] | |||||
if fromreq is not None: | |||||
fromreq = pycompat.sysbytes(fromreq) | |||||
styles = ( | |||||
fromreq, | |||||
configfn('web', 'style'), | |||||
'paper', | |||||
) | |||||
return styles, templater.stylemap(styles, templatepath) | |||||
def makebreadcrumb(url, prefix=''): | def makebreadcrumb(url, prefix=''): | ||||
'''Return a 'URL breadcrumb' list | '''Return a 'URL breadcrumb' list | ||||
A 'URL breadcrumb' is a list of URL-name pairs, | A 'URL breadcrumb' is a list of URL-name pairs, | ||||
corresponding to each of the path items on a URL. | corresponding to each of the path items on a URL. | ||||
This can be used to create path navigation entries. | This can be used to create path navigation entries. | ||||
''' | ''' | ||||
if url.endswith('/'): | if url.endswith('/'): | ||||
# some functions for the templater | # some functions for the templater | ||||
def motd(**map): | def motd(**map): | ||||
yield self.config('web', 'motd', '') | yield self.config('web', 'motd', '') | ||||
# figure out which style to use | # figure out which style to use | ||||
vars = {} | vars = {} | ||||
styles = ( | styles, (style, mapfile) = getstyle(req, self.config, | ||||
req.form.get('style', [None])[0], | self.templatepath) | ||||
self.config('web', 'style'), | |||||
'paper', | |||||
) | |||||
style, mapfile = templater.stylemap(styles, self.templatepath) | |||||
if style == styles[0]: | if style == styles[0]: | ||||
vars['style'] = style | vars['style'] = style | ||||
start = req.url[-1] == '?' and '&' or '?' | start = req.url[-1] == '?' and '&' or '?' | ||||
sessionvars = webutil.sessionvars(vars, start) | sessionvars = webutil.sessionvars(vars, start) | ||||
if not self.reponame: | if not self.reponame: | ||||
self.reponame = (self.config('web', 'name') | self.reponame = (self.config('web', 'name') |
self.updatereqenv(req.env) | self.updatereqenv(req.env) | ||||
url = req.env.get('SCRIPT_NAME', '') | url = req.env.get('SCRIPT_NAME', '') | ||||
if not url.endswith('/'): | if not url.endswith('/'): | ||||
url += '/' | url += '/' | ||||
vars = {} | vars = {} | ||||
styles = ( | styles, (style, mapfile) = hgweb_mod.getstyle(req, config, | ||||
req.form.get('style', [None])[0], | self.templatepath) | ||||
config('web', 'style'), | |||||
'paper' | |||||
) | |||||
style, mapfile = templater.stylemap(styles, self.templatepath) | |||||
if style == styles[0]: | if style == styles[0]: | ||||
vars['style'] = style | vars['style'] = style | ||||
start = url[-1] == '?' and '&' or '?' | start = url[-1] == '?' and '&' or '?' | ||||
sessionvars = webutil.sessionvars(vars, start) | sessionvars = webutil.sessionvars(vars, start) | ||||
logourl = config('web', 'logourl', 'https://mercurial-scm.org/') | logourl = config('web', 'logourl', 'https://mercurial-scm.org/') | ||||
logoimg = config('web', 'logoimg', 'hglogo.png') | logoimg = config('web', 'logoimg', 'hglogo.png') | ||||
staticurl = config('web', 'staticurl') or url + 'static/' | staticurl = config('web', 'staticurl') or url + 'static/' |