Mercurial > hg
annotate tests/test-hgweb-no-path-info @ 7952:b214066b7e1d
rebase: store/restore arguments correctly
Keep and keepbranches were lost after an interruption
author | Stefano Tortarolo <stefano.tortarolo@gmail.com> |
---|---|
date | Sun, 29 Mar 2009 14:43:49 +0200 |
parents | 2cfdabe235fb |
children | 6c82beaaa11a |
rev | line source |
---|---|
6459
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
1 #!/bin/sh |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
2 # This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
3 # no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
4 # should be used from d74fc8dec2b4 onward to route the request. |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
5 |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
6 mkdir repo |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
7 cd repo |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
8 hg init |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
9 echo foo > bar |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
10 hg add bar |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
11 hg commit -m "test" -d "0 0" -u "Testing" |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
12 hg tip |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
13 |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
14 cat > request.py <<EOF |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
15 from mercurial.hgweb import hgweb, hgwebdir |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
16 from StringIO import StringIO |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
17 import os, sys |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
18 |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
19 errors = StringIO() |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
20 input = StringIO() |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
21 |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
22 def startrsp(headers, data): |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
23 print '---- HEADERS' |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
24 print headers |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
25 print '---- DATA' |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
26 print data |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
27 return output.write |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
28 |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
29 env = { |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
30 'wsgi.version': (1, 0), |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
31 'wsgi.url_scheme': 'http', |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
32 'wsgi.errors': errors, |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
33 'wsgi.input': input, |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
34 'wsgi.multithread': False, |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
35 'wsgi.multiprocess': False, |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
36 'wsgi.run_once': False, |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
37 'REQUEST_METHOD': 'GET', |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
38 'SCRIPT_NAME': '', |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
39 'SERVER_NAME': '127.0.0.1', |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
40 'SERVER_PORT': os.environ['HGPORT'], |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
41 'SERVER_PROTOCOL': 'HTTP/1.0' |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
42 } |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
43 |
6945
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
44 def process(app): |
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
45 content = app(env, startrsp) |
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
46 sys.stdout.write(output.getvalue()) |
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
47 sys.stdout.write(''.join(content)) |
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
48 print '---- ERRORS' |
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
49 print errors.getvalue() |
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
50 |
6459
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
51 output = StringIO() |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
52 env['QUERY_STRING'] = 'style=atom' |
6945
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
53 process(hgweb('.', name='repo')) |
6459
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
54 |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
55 output = StringIO() |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
56 env['QUERY_STRING'] = 'style=raw' |
6945
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
57 process(hgwebdir({'repo': '.'})) |
6459
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
58 EOF |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
59 |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
60 python request.py | sed "s/http:\/\/127\.0\.0\.1:[0-9]*\//http:\/\/127.0.0.1\//" |