hgweb: handle exception of misconfigured path on index page stable
authorYuya Nishihara <yuya@tcha.org>
Tue, 24 Aug 2010 23:30:51 +0900
branchstable
changeset 12038 9617803b1acb
parent 12030 927d63be166b
child 12039 18e1e7520b67
hgweb: handle exception of misconfigured path on index page If hgweb.config contains wrong path mapping, hgweb causes internal server error on repository index page. This patch changes makeindex() to ignore RepoError, because it looks to be designed to suppress configuration error.
mercurial/hgweb/hgwebdir_mod.py
tests/test-hgwebdir
tests/test-hgwebdir.out
--- a/mercurial/hgweb/hgwebdir_mod.py	Wed Aug 25 13:29:46 2010 +0200
+++ b/mercurial/hgweb/hgwebdir_mod.py	Tue Aug 24 23:30:51 2010 +0900
@@ -233,6 +233,10 @@
                 # update time with local timezone
                 try:
                     r = hg.repository(self.ui, path)
+                except error.RepoError:
+                    u.warn(_('error accessing repository at %s\n') % path)
+                    continue
+                try:
                     d = (get_mtime(r.spath), util.makedate()[1])
                 except OSError:
                     continue
--- a/tests/test-hgwebdir	Wed Aug 25 13:29:46 2010 +0200
+++ b/tests/test-hgwebdir	Tue Aug 24 23:30:51 2010 +0900
@@ -26,6 +26,10 @@
 echo c > c/c
 hg --cwd c ci -Amc -d'3 0'
 
+# create repository without .hg/store
+hg init nostore
+rm -R nostore/.hg/store
+
 root=`pwd`
 cd ..
 
@@ -112,6 +116,20 @@
 "$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t/?style=raw'
 
 
+"$TESTDIR/killdaemons.py"
+cat > paths.conf <<EOF
+[paths]
+nostore = $root/nostore
+inexistent = $root/inexistent
+EOF
+
+hg serve -p $HGPORT1 -d --pid-file=hg.pid --webdir-conf paths.conf \
+    -A access-paths.log -E error-paths-4.log
+cat hg.pid >> $DAEMON_PIDS
+echo % test inexistent and inaccessible repo should be ignored silently
+"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/'
+
+
 cat > collections.conf <<EOF
 [collections]
 $root=$root
--- a/tests/test-hgwebdir.out	Wed Aug 25 13:29:46 2010 +0200
+++ b/tests/test-hgwebdir.out	Tue Aug 24 23:30:51 2010 +0900
@@ -406,6 +406,45 @@
 /t/a/
 /t/b/
 
+% test inexistent and inaccessible repo should be ignored silently
+200 Script output follows
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
+<head>
+<link rel="icon" href="/static/hgicon.png" type="image/png" />
+<meta name="robots" content="index, nofollow" />
+<link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
+
+<title>Mercurial repositories index</title>
+</head>
+<body>
+
+<div class="container">
+<div class="menu">
+<a href="http://mercurial.selenic.com/">
+<img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
+</div>
+<div class="main">
+<h2>Mercurial Repositories</h2>
+
+<table class="bigtable">
+    <tr>
+        <th><a href="?sort=name">Name</a></th>
+        <th><a href="?sort=description">Description</a></th>
+        <th><a href="?sort=contact">Contact</a></th>
+        <th><a href="?sort=lastchange">Last modified</a></th>
+        <th>&nbsp;</th>
+    </tr>
+    
+</table>
+</div>
+</div>
+
+
+</body>
+</html>
+
 % collections: should succeed
 200 Script output follows