|
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" -d "0 0" -u "Testing" |
|
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(headers, data): |
|
23 print '---- HEADERS' |
|
24 print headers |
|
25 print '---- DATA' |
|
26 print data |
|
27 return output.write |
|
28 |
|
29 env = { |
|
30 'wsgi.version': (1, 0), |
|
31 'wsgi.url_scheme': 'http', |
|
32 'wsgi.errors': errors, |
|
33 'wsgi.input': input, |
|
34 'wsgi.multithread': False, |
|
35 'wsgi.multiprocess': False, |
|
36 'wsgi.run_once': False, |
|
37 'REQUEST_METHOD': 'GET', |
|
38 'SCRIPT_NAME': '', |
|
39 'SERVER_NAME': '127.0.0.1', |
|
40 'SERVER_PORT': os.environ['HGPORT'], |
|
41 'SERVER_PROTOCOL': 'HTTP/1.0' |
|
42 } |
|
43 |
|
44 output = StringIO() |
|
45 env['QUERY_STRING'] = 'style=atom' |
|
46 hgweb('.', name = 'repo')(env, startrsp) |
|
47 print output.getvalue() |
|
48 print '---- ERRORS' |
|
49 print errors.getvalue() |
|
50 |
|
51 output = StringIO() |
|
52 env['QUERY_STRING'] = 'style=raw' |
|
53 hgwebdir({'repo': '.'})(env, startrsp) |
|
54 print output.getvalue() |
|
55 print '---- ERRORS' |
|
56 print errors.getvalue() |
|
57 EOF |
|
58 |
|
59 python request.py | sed "s/http:\/\/127\.0\.0\.1:[0-9]*\//http:\/\/127.0.0.1\//" |