[PATCH 5 of 8] hgweb: drop archivespecs from requestcontext

Yuya Nishihara yuya at tcha.org
Tue Apr 10 11:41:38 EDT 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1522589635 -32400
#      Sun Apr 01 22:33:55 2018 +0900
# Node ID cf2d909fdec997a9bb39573ded50ae362a667221
# Parent  1dd6d286577ee108d2b643f320bf22e72823b47d
hgweb: drop archivespecs from requestcontext

It's a constant.

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
@@ -90,8 +90,6 @@ class requestcontext(object):
         self.req = req
         self.res = res
 
-        self.archivespecs = webutil.archivespecs
-
         self.maxchanges = self.configint('web', 'maxchanges')
         self.stripecount = self.configint('web', 'stripes')
         self.maxshortchanges = self.configint('web', 'maxshortchanges')
@@ -131,7 +129,7 @@ class requestcontext(object):
 
     def archivelist(self, nodeid):
         allowed = self.configlist('web', 'allow_archive')
-        for typ, spec in self.archivespecs.iteritems():
+        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}
 
@@ -375,7 +373,7 @@ class hgweb(object):
 
             if cmd == 'archive':
                 fn = req.qsparams['node']
-                for type_, spec in rctx.archivespecs.iteritems():
+                for type_, spec in webutil.archivespecs.iteritems():
                     ext = spec[2]
                     if fn.endswith(ext):
                         req.qsparams['node'] = fn[:-len(ext)]
diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -1164,7 +1164,7 @@ def archive(web):
     allowed = web.configlist("web", "allow_archive")
     key = web.req.qsparams['node']
 
-    if type_ not in web.archivespecs:
+    if type_ not in webutil.archivespecs:
         msg = 'Unsupported archive type: %s' % type_
         raise ErrorResponse(HTTP_NOT_FOUND, msg)
 
@@ -1193,7 +1193,7 @@ def archive(web):
                 raise ErrorResponse(HTTP_NOT_FOUND,
                     'file(s) not found: %s' % file)
 
-    mimetype, artype, extension, encoding = web.archivespecs[type_]
+    mimetype, artype, extension, encoding = webutil.archivespecs[type_]
 
     web.res.headers['Content-Type'] = mimetype
     web.res.headers['Content-Disposition'] = 'attachment; filename=%s%s' % (


More information about the Mercurial-devel mailing list