[PATCH 1 of 1 stable resend] hgweb: handle exception of misconfigured path on index page

Mads Kiilerich mads at kiilerich.com
Tue Aug 24 14:38:42 CDT 2010


  Yuya Nishihara wrote, On 08/24/2010 04:47 PM:
> # HG changeset patch
> # User Yuya Nishihara<yuya at tcha.org>
> # Date 1282660251 -32400
> # Branch stable
> # Node ID 72c2c888d23eb3ca92bdaf81cb697581adc60ce1
> # Parent  b20211b307b39ed2dbfbe992d94d0f1a24e63e13
> 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.
>
> 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
> @@ -233,6 +233,10 @@ class hgwebdir(object):
>                   # 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.out
> +++ b/tests/test-hgwebdir.out
> @@ -406,6 +406,45 @@ 200 Script output follows
>   /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>
> +

The warning don't show up in the test output? That makes me wonder if 
u.warn really is the right method to use?

It could be argued that a crash is more friendly to the system 
administrator than silently ignoring errors.

/Mads


More information about the Mercurial-devel mailing list