hgweb: add web.descend configuration variable
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Wed, 19 Aug 2009 12:47:04 +0200
changeset 9363 8635b33eaade
parent 9362 bb7e2cdd4854
child 9364 c7c2dd7524dd
hgweb: add web.descend configuration variable
doc/hgrc.5.txt
mercurial/hgweb/hgwebdir_mod.py
tests/test-hgwebdir
tests/test-hgwebdir.out
--- a/doc/hgrc.5.txt	Tue Aug 18 13:59:30 2009 +0200
+++ b/doc/hgrc.5.txt	Wed Aug 19 12:47:04 2009 +0200
@@ -873,6 +873,10 @@
     the list of repositories. The contents of the deny_read list have
     priority over (are examined before) the contents of the allow_read
     list.
+``descend``
+    hgwebdir indexes will not descend into subdirectories. Only repositories
+    directly in the current path will be shown (other repositories are still
+    available from the index corresponding to their containing path).
 ``description``
     Textual description of the repository's purpose or contents.
     Default is "unknown".
--- a/mercurial/hgweb/hgwebdir_mod.py	Tue Aug 18 13:59:30 2009 +0200
+++ b/mercurial/hgweb/hgwebdir_mod.py	Wed Aug 19 12:47:04 2009 +0200
@@ -198,12 +198,17 @@
 
         sortdefault = 'name', False
         def entries(sortcolumn="", descending=False, subdir="", **map):
+
             rows = []
             parity = paritygen(self.stripecount)
+            descend = self.ui.configbool('web', 'descend', True)
             for name, path in self.repos:
+
                 if not name.startswith(subdir):
                     continue
                 name = name[len(subdir):]
+                if not descend and '/' in name:
+                    continue
 
                 u = self.ui.copy()
                 try:
--- a/tests/test-hgwebdir	Tue Aug 18 13:59:30 2009 +0200
+++ b/tests/test-hgwebdir	Wed Aug 19 12:47:04 2009 +0200
@@ -29,6 +29,7 @@
 root=`pwd`
 cd ..
 
+
 cat > paths.conf <<EOF
 [paths]
 a=$root/a
@@ -50,6 +51,7 @@
 echo % should give a 404 - repo is not published
 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/c/file/tip/c?style=raw'
 
+
 cat > paths.conf <<EOF
 [paths]
 t/a/=$root/a
@@ -83,6 +85,24 @@
 "$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/rcoll/b/d/file/tip/d?style=raw'
 
 
+"$TESTDIR/killdaemons.py"
+cat > paths.conf <<EOF
+[paths]
+t/a = $root/a
+t/b = $root/b
+c = $root/c
+[web]
+descend=false
+EOF
+
+hg serve -p $HGPORT1 -d --pid-file=hg.pid --webdir-conf paths.conf \
+    -A access-paths.log -E error-paths-3.log
+cat hg.pid >> $DAEMON_PIDS
+echo % test descend = False
+"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/?style=raw'
+"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t/?style=raw'
+
+
 cat > collections.conf <<EOF
 [collections]
 $root=$root
@@ -99,9 +119,12 @@
 "$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/b/file/tip/b?style=raw'
 "$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/c/file/tip/c?style=raw'
 
+
 echo % paths errors 1
 cat error-paths-1.log
 echo % paths errors 2
 cat error-paths-2.log
+echo % paths errors 3
+cat error-paths-3.log
 echo % collections errors
 cat error-collections.log
--- a/tests/test-hgwebdir.out	Tue Aug 18 13:59:30 2009 +0200
+++ b/tests/test-hgwebdir.out	Wed Aug 19 12:47:04 2009 +0200
@@ -307,6 +307,18 @@
 200 Script output follows
 
 d
+% test descend = False
+200 Script output follows
+
+
+/c/
+
+200 Script output follows
+
+
+/t/a/
+/t/b/
+
 % collections: should succeed
 200 Script output follows
 
@@ -327,4 +339,5 @@
 c
 % paths errors 1
 % paths errors 2
+% paths errors 3
 % collections errors