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

Yuya Nishihara yuya at tcha.org
Tue Aug 24 14:47:10 UTC 2010


Mads Kiilerich wrote:
>   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.

Indeed.
Resent the patch with a test.

I also added a test for OSError, but it looks less common to raise OSError,
because in most case, RepoError is raised before reaching get_mtime(r.spath).
OSError handling is added at 0d47bb884330.

Yuya,


More information about the Mercurial-devel mailing list