Add urlhost option

Mads Kiilerich mads at kiilerich.com
Fri Nov 4 06:15:43 CDT 2011


On 11/04/2011 10:04 AM, Schueler.external at lantiq.com wrote:
> Add an option to make host used for RSS and Atom links configurable
>
> 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


More information about the Mercurial-devel mailing list