# HG changeset patch # User TK Soh # Date 1149174144 18000 # Node ID 8819fc1dcf4bca186d4440fb5b402e243f94333f # Parent 4a7bdb1e8dc18724f130406e11bda01848549f9b hgweb: add allow_archive support to [web] section of hgrc diff --git a/doc/hgrc.5.txt b/doc/hgrc.5.txt --- a/doc/hgrc.5.txt +++ b/doc/hgrc.5.txt @@ -362,15 +362,20 @@ web:: Where to output the access log. Default is stdout. address;; Interface address to bind to. Default is all. + allow_archive;; + List of archive format (bz2, gz, zip) allowed for downloading. + Default is empty. allowbz2;; - Whether to allow .tar.bz2 downloading of repo revisions. Default is false. + (DEPRECATED) Whether to allow .tar.bz2 downloading of repo revisions. + Default is false. allowgz;; - Whether to allow .tar.gz downloading of repo revisions. Default is false. + (DEPRECATED) Whether to allow .tar.gz downloading of repo revisions. + Default is false. allowpull;; Whether to allow pulling from the repository. Default is true. allowzip;; - Whether to allow .zip downloading of repo revisions. Default is false. - This feature creates temporary files. + (DEPRECATED) Whether to allow .zip downloading of repo revisions. + Default is false. This feature creates temporary files. baseurl;; Base URL to use when publishing URLs in other locations, so third-party tools like email notification hooks can construct URLs. 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 @@ -48,8 +48,9 @@ class hgweb(object): self.allowpull = self.repo.ui.configbool("web", "allowpull", True) def archivelist(self, nodeid): + al = self.repo.ui.config("web", "allow_archive", "").split() for i in self.archives: - if self.repo.ui.configbool("web", "allow" + i, False): + if i in al or self.repo.ui.configbool("web", "allow" + i, False): yield {"type" : i, "node" : nodeid, "url": ""} def listfiles(self, files, mf): @@ -803,8 +804,9 @@ class hgweb(object): elif cmd == 'archive': changeset = self.repo.lookup(req.form['node'][0]) type = req.form['type'][0] - if (type in self.archives and - self.repo.ui.configbool("web", "allow" + type, False)): + allowed = self.repo.ui.config("web", "allow_archive", "").split() + if (type in self.archives and (type in allowed or + self.repo.ui.configbool("web", "allow" + type, False))): self.archive(req, changeset, type) return diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -58,8 +58,9 @@ class hgwebdir(object): "footer": footer}) def archivelist(ui, nodeid, url): + al = ui.config("web", "allow_archive", "").split() for i in ['zip', 'gz', 'bz2']: - if ui.configbool("web", "allow" + i, False): + if i in al or ui.configbool("web", "allow" + i, False): yield {"type" : i, "node": nodeid, "url": url} def entries(sortcolumn="", descending=False, **map):