changeset 2358:8819fc1dcf4b

hgweb: add allow_archive support to [web] section of hgrc
author TK Soh <teekaysoh@yahoo.com>
date Thu, 01 Jun 2006 10:02:24 -0500
parents 4a7bdb1e8dc1
children a392eaa81f29
files doc/hgrc.5.txt mercurial/hgweb/hgweb_mod.py mercurial/hgweb/hgwebdir_mod.py
diffstat 3 files changed, 16 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/doc/hgrc.5.txt	Wed May 31 14:16:21 2006 -0700
+++ b/doc/hgrc.5.txt	Thu Jun 01 10:02:24 2006 -0500
@@ -362,15 +362,20 @@
     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.
--- a/mercurial/hgweb/hgweb_mod.py	Wed May 31 14:16:21 2006 -0700
+++ b/mercurial/hgweb/hgweb_mod.py	Thu Jun 01 10:02:24 2006 -0500
@@ -48,8 +48,9 @@
             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 @@
         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
 
--- a/mercurial/hgweb/hgwebdir_mod.py	Wed May 31 14:16:21 2006 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py	Thu Jun 01 10:02:24 2006 -0500
@@ -58,8 +58,9 @@
                                              "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):