[PATCH V4] hgwebdir: allow a repository to be hosted at "/"

Matt Harbison mharbison72 at gmail.com
Mon Apr 17 20:34:16 EDT 2017


On Mon, 17 Apr 2017 18:40:22 -0400, Sean Farley <sean at farley.io> wrote:

> Kevin Bullock <kbullock+mercurial at ringworld.org> writes:
>
>>> On Apr 15, 2017, at 14:34, Matt Harbison <mharbison72 at gmail.com> wrote:
>>>
>>> # HG changeset patch
>>> # User Matt Harbison <matt_harbison at yahoo.com>
>>> # Date 1491015641 14400
>>> #      Fri Mar 31 23:00:41 2017 -0400
>>> # Node ID 3fd50d5f9314a96f43eb73480763f224c4d05831
>>> # Parent  4c2c30bc38b4f84ce8f215146bbf158e299065b3
>>> hgwebdir: allow a repository to be hosted at "/"
>>>
>>> This can be useful in general, but will also be useful for hosting  
>>> subrepos,
>>> with the main repo at /.
>>>
>>> diff --git a/mercurial/hgweb/hgweb_mod.py  
>>> b/mercurial/hgweb/hgweb_mod.py
>>> --- a/mercurial/hgweb/hgweb_mod.py
>>> +++ b/mercurial/hgweb/hgweb_mod.py
>>> @@ -335,7 +335,7 @@
>>>         req.url = req.env['SCRIPT_NAME']
>>>         if not req.url.endswith('/'):
>>>             req.url += '/'
>>> -        if 'REPO_NAME' in req.env:
>>> +        if req.env.get('REPO_NAME'):
>>
>> Since we don't need the value returned from .get(), is there some other  
>> reason for this change that I'm not seeing?
>
> 'REPO_NAME' is used in the next line, so I guess this was supposed to
> be:
>
> foo = req.env.get('REPO_NAME')
> if foo:
>     req.url += foo + '/'
>
> ?

Yeah, that's more clear.  A couple lines later also calls  
"req.env.get('REPO_NAME')", so it's probably worth a local variable.

Without this check, links in index.html change like this:

--- c:/Users/Matt/Projects/hg/tests/test-hgwebdir.t
+++ c:/Users/Matt/Projects/hg/tests/test-hgwebdir.t.err
@@ -1692,7 +1692,7 @@

    $ get-with-headers.py localhost:$HGPORT1 '' | grep 'index'
    <meta name="robots" content="index, nofollow" />
-     <a href="/rev/71a89161f014">add index file</a>
+     <a href="//rev/71a89161f014">add index file</a>

    $ killdaemons.py


More information about the Mercurial-devel mailing list