# HG changeset patch # User Yuya Nishihara # Date 1522589823 -32400 # Node ID 40a7c1dd2df950062924d95699f3e09ab2d3e024 # Parent aac97d043e6db5c2309af99d308643150354f595 hgweb: move archivelist() of hgwebdir to webutil diff -r aac97d043e6d -r 40a7c1dd2df9 mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py Sun Apr 01 22:33:55 2018 +0900 +++ b/mercurial/hgweb/hgwebdir_mod.py Sun Apr 01 22:37:03 2018 +0900 @@ -105,22 +105,6 @@ return False -def archivelist(ui, nodeid, url): - allowed = ui.configlist('web', 'allow_archive', untrusted=True) - archives = [] - - for typ, spec in webutil.archivespecs.iteritems(): - if typ in allowed or ui.configbool('web', 'allow' + typ, - untrusted=True): - archives.append({ - 'type': typ, - 'extension': spec[2], - 'node': nodeid, - 'url': url, - }) - - return archives - def rawindexentries(ui, repos, req, subdir=''): descend = ui.configbool('web', 'descend') collapse = ui.configbool('web', 'collapse') @@ -241,7 +225,7 @@ 'description_sort': description.upper() or "unknown", 'lastchange': d, 'lastchange_sort': d[1] - d[0], - 'archives': archivelist(u, "tip", url), + 'archives': webutil.archivelist(u, "tip", url), 'isdirectory': None, 'labels': templateutil.hybridlist(labels, name='label'), } diff -r aac97d043e6d -r 40a7c1dd2df9 mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py Sun Apr 01 22:33:55 2018 +0900 +++ b/mercurial/hgweb/webutil.py Sun Apr 01 22:37:03 2018 +0900 @@ -49,6 +49,22 @@ ('bz2', ('application/x-bzip2', 'tbz2', '.tar.bz2', None)), )) +def archivelist(ui, nodeid, url): + allowed = ui.configlist('web', 'allow_archive', untrusted=True) + archives = [] + + for typ, spec in archivespecs.iteritems(): + if typ in allowed or ui.configbool('web', 'allow' + typ, + untrusted=True): + archives.append({ + 'type': typ, + 'extension': spec[2], + 'node': nodeid, + 'url': url, + }) + + return archives + def up(p): if p[0:1] != "/": p = "/" + p