[PATCH 1 of 1] hgwebdir_mod.py can now handle 'baseurl' configurations with leading slash
Mads Kiilerich
mads at kiilerich.com
Mon Aug 1 09:18:33 CDT 2011
> Basically, the leading slash is now always added to the baseurl path at the
> beginning, which results in mercurial generating links with double slashes,
> like '//hg/static/logo.png'.
A clarification: The problem is that the browser interprets that as
http://hg/static/logo.png instead of as /hg/static/logo.png .
Another part of the problem seems to be that normpath doesn't remove
double leading slashes because it assumes that it means what it means.
The patch looks good to me. It seems like this also fixes some issues if
baseurl is empty (the default), but I haven't tried hard enough to
figure out what was going on. You could perhaps add a test case for that
too.
On 08/01/2011 12:03 PM, wujek.srujek at googlemail.com wrote:
> # HG changeset patch
> # User wujek
> # Date 1312184890 -7200
> # Node ID 060a118fc62277c5cd71751503db19a7b4183a21
> # Parent cc2c22511707b13d045f17bb34e865d2393c53cf
> hgwebdir_mod.py can now handle 'baseurl' configurations with leading slash
FYI http://mercurial.selenic.com/wiki/ContributingChanges has something
to say about patch descriptions - especially 'start with subsystem' and
bug tracker issues. The first line could be something like:
hgweb: handle 'baseurl' configurations with leading slash (issue2934)
Some of the description and analysis from your intro mail (and perhaps
some of my comments above) could also be nice to have in the description.
> diff -r cc2c22511707 -r 060a118fc622 mercurial/hgweb/hgwebdir_mod.py
> --- a/mercurial/hgweb/hgwebdir_mod.py Fri Jul 29 17:27:38 2011 -0500
> +++ b/mercurial/hgweb/hgwebdir_mod.py Mon Aug 01 09:48:10 2011 +0200
> @@ -370,4 +370,7 @@
> env['SERVER_NAME'] = u.host
> if u.port:
> env['SERVER_PORT'] = u.port
> - env['SCRIPT_NAME'] = '/' + u.path
> + path = u.path
> + if not path.startswith('/'):
> + path = '/' + path
> + env['SCRIPT_NAME'] = path
> diff -r cc2c22511707 -r 060a118fc622 tests/test-hgwebdir-baseurl.py
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/tests/test-hgwebdir-baseurl.py Mon Aug 01 09:48:10 2011 +0200
We would like to avoid having one test file for each bugfix. Could this
test perhaps be combined with tests/test-hgwebdir-paths.py or be tested
like other baseurl stuff is tested in tests/test-hgwebdir.t ?
> @@ -0,0 +1,22 @@
> +from mercurial.hgweb.hgwebdir_mod import hgwebdir
> +
> +
> +class hgwebdir_test(hgwebdir):
> +
> + def __init__(self, baseurl):
> + self._baseurl = baseurl
> +
> +
> +def test_baseurl(path, expected = None):
> + mock = hgwebdir_test(path)
> + env = {}
> + mock.updatereqenv(env)
> + if expected is None:
> + assert 'SCRIPT_NAME' not in env
> + else:
> + assert env['SCRIPT_NAME'] == expected
> +
> +
> +test_baseurl('/hg', '/hg')
> +test_baseurl('hg', '/hg')
> +test_baseurl(None)
/Mads
More information about the Mercurial-devel
mailing list