[PATCH stable] hgweb: handle exception of misconfigured path on index page
Mads Kiilerich
mads at kiilerich.com
Mon Aug 23 14:54:18 CDT 2010
Yuya Nishihara wrote, On 08/23/2010 06:29 PM:
> # HG changeset patch
> # User Yuya Nishihara<yuya at tcha.org>
> # Date 1282580862 -32400
> # Node ID d76eb7dd56cdb816cf38b10b05a4c76a0fbb5936
> # Parent 2315a95ee88759ad2ed250dcbf2fc93be4073688
> 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
> @@ -234,7 +234,8 @@ class hgwebdir(object):
> try:
> r = hg.repository(self.ui, path)
> d = (get_mtime(r.spath), util.makedate()[1])
> - except OSError:
> + except (OSError, error.RepoError):
> + u.warn(_('error getting repository mtime %s\n') % path)
> continue
Is that message helpful in the RepoError case? It seems confusingly
specific.
I assume the RepoError happens in hg.repository which isn't likely to
throw OSError? Perhaps hg.repository could be placed in a separate
try/except and give a "error accessing repository at %s\n" warning instead.
Could you add a test for this? (It could be nice to have a test for
OSError/failing mtime too.)
/Mads
More information about the Mercurial-devel
mailing list