Patchwork [7,of,8] hgweb: forward archivelist() of hgweb to webutil

login
register
mail settings
Submitter Yuya Nishihara
Date April 10, 2018, 3:41 p.m.
Message ID <d9f6292315ef2e0000e3.1523374900@mimosa>
Download mbox | patch
Permalink /patch/30638/
State Accepted
Headers show

Comments

Yuya Nishihara - April 10, 2018, 3:41 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522590015 -32400
#      Sun Apr 01 22:40:15 2018 +0900
# Node ID d9f6292315ef2e0000e355cccc3a6dc10c20eefd
# Parent  f698f65fbaf88305353eb769e0130299fc747f08
hgweb: forward archivelist() of hgweb to webutil

self.configlist() is ui.configlist(untrusted=True), and url=None in templater
effectively means 'url' is undefined.

Patch

diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -128,10 +128,7 @@  class requestcontext(object):
                                        untrusted=untrusted)
 
     def archivelist(self, nodeid):
-        allowed = self.configlist('web', 'allow_archive')
-        for typ, spec in webutil.archivespecs.iteritems():
-            if typ in allowed or self.configbool('web', 'allow%s' % typ):
-                yield {'type': typ, 'extension': spec[2], 'node': nodeid}
+        return webutil.archivelist(self.repo.ui, nodeid)
 
     def templater(self, req):
         # determine scheme, port and server name
diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -49,7 +49,7 @@  archivespecs = util.sortdict((
     ('bz2', ('application/x-bzip2', 'tbz2', '.tar.bz2', None)),
 ))
 
-def archivelist(ui, nodeid, url):
+def archivelist(ui, nodeid, url=None):
     allowed = ui.configlist('web', 'allow_archive', untrusted=True)
     archives = []