# HG changeset patch # User Anton Shestakov # Date 1484062479 -28800 # Node ID 319914d57b9e32ef80324f6c751ac2ca8c8f648b # Parent 4259df518223d72646c7688164c6f4924bbf2c5c hgweb: use util.sortdict for archivespecs Thus we allow dict-like indexing and "in" checks, and also preserve the order of archive types and can generate links in a certain order (so requestcontext.archives is no longer needed). diff -r 4259df518223 -r 319914d57b9e mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py Wed Jan 11 01:25:07 2017 +0800 +++ b/mercurial/hgweb/hgweb_mod.py Tue Jan 10 23:34:39 2017 +0800 @@ -89,8 +89,6 @@ self.repo = repo self.reponame = app.reponame - self.archives = ('zip', 'gz', 'bz2') - self.maxchanges = self.configint('web', 'maxchanges', 10) self.stripecount = self.configint('web', 'stripes', 1) self.maxshortchanges = self.configint('web', 'maxshortchanges', 60) @@ -126,16 +124,15 @@ return self.repo.ui.configlist(section, name, default, untrusted=untrusted) - archivespecs = { - 'bz2': ('application/x-bzip2', 'tbz2', '.tar.bz2', None), - 'gz': ('application/x-gzip', 'tgz', '.tar.gz', None), - 'zip': ('application/zip', 'zip', '.zip', None), - } + archivespecs = util.sortdict(( + ('zip', ('application/zip', 'zip', '.zip', None)), + ('gz', ('application/x-gzip', 'tgz', '.tar.gz', None)), + ('bz2', ('application/x-bzip2', 'tbz2', '.tar.bz2', None)), + )) def archivelist(self, nodeid): allowed = self.configlist('web', 'allow_archive') - for typ in self.archives: - spec = self.archivespecs[typ] + for typ, spec in self.archivespecs.iteritems(): if typ in allowed or self.configbool('web', 'allow%s' % typ): yield {'type': typ, 'extension': spec[2], 'node': nodeid}