1 #!/bin/sh |
|
2 # This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is |
|
3 # no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO |
|
4 # should be used from d74fc8dec2b4 onward to route the request. |
|
5 |
|
6 mkdir repo |
|
7 cd repo |
|
8 hg init |
|
9 echo foo > bar |
|
10 hg add bar |
|
11 hg commit -m "test" |
|
12 hg tip |
|
13 |
|
14 cat > request.py <<EOF |
|
15 from mercurial.hgweb import hgweb, hgwebdir |
|
16 from StringIO import StringIO |
|
17 import os, sys |
|
18 |
|
19 errors = StringIO() |
|
20 input = StringIO() |
|
21 |
|
22 def startrsp(status, headers): |
|
23 print '---- STATUS' |
|
24 print status |
|
25 print '---- HEADERS' |
|
26 print [i for i in headers if i[0] != 'ETag'] |
|
27 print '---- DATA' |
|
28 return output.write |
|
29 |
|
30 env = { |
|
31 'wsgi.version': (1, 0), |
|
32 'wsgi.url_scheme': 'http', |
|
33 'wsgi.errors': errors, |
|
34 'wsgi.input': input, |
|
35 'wsgi.multithread': False, |
|
36 'wsgi.multiprocess': False, |
|
37 'wsgi.run_once': False, |
|
38 'REQUEST_METHOD': 'GET', |
|
39 'SCRIPT_NAME': '', |
|
40 'SERVER_NAME': '127.0.0.1', |
|
41 'SERVER_PORT': os.environ['HGPORT'], |
|
42 'SERVER_PROTOCOL': 'HTTP/1.0' |
|
43 } |
|
44 |
|
45 def process(app): |
|
46 content = app(env, startrsp) |
|
47 sys.stdout.write(output.getvalue()) |
|
48 sys.stdout.write(''.join(content)) |
|
49 print '---- ERRORS' |
|
50 print errors.getvalue() |
|
51 |
|
52 output = StringIO() |
|
53 env['QUERY_STRING'] = 'style=atom' |
|
54 process(hgweb('.', name='repo')) |
|
55 |
|
56 output = StringIO() |
|
57 env['QUERY_STRING'] = 'style=raw' |
|
58 process(hgwebdir({'repo': '.'})) |
|
59 EOF |
|
60 |
|
61 python request.py | sed "s/http:\/\/127\.0\.0\.1:[0-9]*\//http:\/\/127.0.0.1\//" |
|