Add urlhost option

Mads Kiilerich mads at kiilerich.com
Tue Jan 3 07:31:46 CST 2012


On 01/03/2012 01:52 PM, Nikolaus.Schueler at lantiq.com wrote:
> Hi Mads,
>
>>> This patch is useful if you want your links to point to a
>> different
>>> server than the one the repo is hosted on. In our setup, the
>> repos are
>>> hosted on backend servers, while access to them is through a
>> frontend
>>> server, so the links for RSS and Atom were wrong, they pointed to
>> the
>>> backend server instead of the frontend. The reason for this is
>> that the
>>> URLs were composed from the SERVERNAME which always contains the
>> name of
>>> the server on which the repo is hosted.
>>>
>>> We introduced an additional config setting, urlhost, that allows
>> you to
>>> specify the server to which the links should point.
>> ...
>>> --- a/mercurial/help/config.txt
>>> +++ b/mercurial/help/config.txt
>>> @@ -1291,3 +1291,7 @@ The full set of options is:
>>>
>>>    ``templates``
>>>        Where to find the HTML templates. Default is install path.
>>> +
>>> +``urlhost``
>>> +   Name of the host that is used in ``urlbase``. If not
>> specified, it defaults
>>> +   to ``SERVER_NAME``.
>>> 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
>>> @@ -233,7 +233,11 @@ class hgweb(object):
>>>
>>>            port = req.env["SERVER_PORT"]
>>>            port = port != default_port and (":" + port) or ""
>>> -        urlbase = '%s://%s%s' % (proto, req.env['SERVER_NAME'],
>> port)
>>> +        urlhost = self.config('web', 'urlhost')
>>> +        if urlhost is None:
>>> +            urlhost = req.env['SERVER_NAME']
>>> +
>>> +        urlbase = '%s://%s%s' % (proto, urlhost, port)
>>
>> Looking at the code it seems like it would be better to make
>> urlbase
>> configurable. That would also solve the issue when the frontend
>> uses a
>> different protocol and port than the backend.
>>
>> But according to the documentation we already have a baseurl
>> configuration option that should cover your need as well. It is
>> tested
>> in tests/test-hgwebdir.t. It seems like the real issue here is that
>> this
>> option only is used for serving multiple repositories, not for
>> simple
>> serving of a single repository. I think it would be better to solve
>> that
>> instead.
>>
>> /Mads
>
> I tried it out, using baseurl in that way does not work. Extending
> baseurl to templating in hgweb_mod breaks current behavior. When you
> set baseurl to get the desired behavior for the hgweb_mod case, you
> also break URLs in hgwebdir_mod. So we would indeed need an option
> that only affects templating for hgweb_mod, as in my patch.

How do you extend baseurl to templating in hgweb_mod, and how does it 
break current behaviour?

Is it inherently and conceptually broken, or is just an indication that 
it should be implemented differently?

/Mads


More information about the Mercurial-devel mailing list