##// END OF EJS Templates
hgweb: support constructing URLs from an alternate base URL...
hgweb: support constructing URLs from an alternate base URL The web.baseurl config option allows server operators to define a custom URL for hosted content. The way it works today is that hgwebdir parses this config option into URL components then updates the appropriate WSGI environment variables so the request "lies" about its details. For example, SERVER_NAME is updated to reflect the alternate base URL's hostname. The WSGI environment should not be modified because WSGI applications may want to know the original request details (for debugging, etc). This commit teaches our request parser about the existence of an alternate base URL. If defined, the advertised URL and other self-reflected paths will take the alternate base URL into account. The hgweb WSGI application didn't use web.baseurl. But hgwebdir did. We update hgwebdir to alter the environment parsing accordingly. The old code around environment manipulation has been removed. With this change, parserequestfromenv() has grown to a bit unwieldy. Now that practically everyone is using it, it is obvious that there is some unused features that can be trimmed. So look for this in follow-up commits. Differential Revision: https://phab.mercurial-scm.org/D2822

File last commit:

r27982:bf1d5c22 default
r36916:219b2335 default
Show More
test-schemes.t
74 lines | 1.4 KiB | text/troff | Tads3Lexer
Matt Mackall
tests: replace exit 80 with #require
r22046 #require serve
Matt Mackall
tests: unify test-schemes
r12486
$ cat <<EOF >> $HGRCPATH
> [extensions]
> schemes=
>
> [schemes]
> l = http://localhost:$HGPORT/
> parts = http://{1}:$HGPORT/
> z = file:\$PWD/
> EOF
$ hg init test
$ cd test
$ echo a > a
$ hg ci -Am initial
adding a
Mads Kiilerich
scheme: don't crash on invalid URLs
r18910
invalid scheme
$ hg log -R z:z
abort: no '://' in scheme url 'z:z'
[255]
http scheme
Matt Mackall
tests: unify test-schemes
r12486 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
$ cat hg.pid >> $DAEMON_PIDS
$ hg incoming l://
comparing with l://
searching for changes
no changes found
[1]
check that {1} syntax works
$ hg incoming --debug parts://localhost
Mads Kiilerich
tests: reintroduce ":$HGPORT" in test output...
r12643 using http://localhost:$HGPORT/
Peter Arrenbrecht
httprepo: use caps instead of between for compat check...
r13603 sending capabilities command
Brodie Rao
url: add trailing slashes to URLs with hostnames that don't have one...
r13815 comparing with parts://localhost/
Peter Arrenbrecht
discovery: add new set-based discovery...
r14164 query 1; heads
Peter Arrenbrecht
setdiscovery: batch heads and known(ownheads)...
r14624 sending batch command
Matt Mackall
tests: unify test-schemes
r12486 searching for changes
Peter Arrenbrecht
discovery: add new set-based discovery...
r14164 all remote heads known locally
Matt Mackall
tests: unify test-schemes
r12486 no changes found
[1]
check that paths are expanded
$ PWD=`pwd` hg incoming z://
comparing with z://
searching for changes
no changes found
[1]
Jason R. Coombs
schemes: add debugexpandscheme command, resolving a scheme to canonical form
r27982 check that debugexpandscheme outputs the canonical form
$ hg debugexpandscheme bb://user/repo
https://bitbucket.org/user/repo
expanding an unknown scheme emits the input
$ hg debugexpandscheme foobar://this/that
foobar://this/that
expanding a canonical URL emits the input
$ hg debugexpandscheme https://bitbucket.org/user/repo
https://bitbucket.org/user/repo
Matt Mackall
tests: unify test-schemes
r12486 errors
$ cat errors.log
Mads Kiilerich
tests: add missing trailing 'cd ..'...
r16913
$ cd ..