Merge from crew-stable.
--- a/mercurial/hgweb/hgweb_mod.py Thu Apr 03 11:18:43 2008 +0200
+++ b/mercurial/hgweb/hgweb_mod.py Thu Apr 03 13:21:42 2008 +0200
@@ -123,8 +123,8 @@
if 'REPO_NAME' in req.env:
req.url += req.env['REPO_NAME'] + '/'
- if req.env.get('PATH_INFO'):
- parts = req.env.get('PATH_INFO').strip('/').split('/')
+ if 'PATH_INFO' in req.env:
+ parts = req.env['PATH_INFO'].strip('/').split('/')
repo_parts = req.env.get('REPO_NAME', '').split('/')
if parts[:len(repo_parts)] == repo_parts:
parts = parts[len(repo_parts):]
--- a/mercurial/hgweb/hgwebdir_mod.py Thu Apr 03 11:18:43 2008 +0200
+++ b/mercurial/hgweb/hgwebdir_mod.py Thu Apr 03 13:21:42 2008 +0200
@@ -181,7 +181,9 @@
if u.configbool("web", "hidden", untrusted=True):
continue
- parts = [req.env['PATH_INFO'].rstrip('/'), name]
+ parts = [name]
+ if 'PATH_INFO' in req.env:
+ parts.insert(0, req.env['PATH_INFO'].rstrip('/'))
if req.env['SCRIPT_NAME']:
parts.insert(0, req.env['SCRIPT_NAME'])
url = ('/'.join(parts).replace("//", "/")) + '/'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-hgweb-no-path-info Thu Apr 03 13:21:42 2008 +0200
@@ -0,0 +1,59 @@
+#!/bin/sh
+# This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is
+# no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO
+# should be used from d74fc8dec2b4 onward to route the request.
+
+mkdir repo
+cd repo
+hg init
+echo foo > bar
+hg add bar
+hg commit -m "test" -d "0 0" -u "Testing"
+hg tip
+
+cat > request.py <<EOF
+from mercurial.hgweb import hgweb, hgwebdir
+from StringIO import StringIO
+import os, sys
+
+errors = StringIO()
+input = StringIO()
+
+def startrsp(headers, data):
+ print '---- HEADERS'
+ print headers
+ print '---- DATA'
+ print data
+ return output.write
+
+env = {
+ 'wsgi.version': (1, 0),
+ 'wsgi.url_scheme': 'http',
+ 'wsgi.errors': errors,
+ 'wsgi.input': input,
+ 'wsgi.multithread': False,
+ 'wsgi.multiprocess': False,
+ 'wsgi.run_once': False,
+ 'REQUEST_METHOD': 'GET',
+ 'SCRIPT_NAME': '',
+ 'SERVER_NAME': '127.0.0.1',
+ 'SERVER_PORT': os.environ['HGPORT'],
+ 'SERVER_PROTOCOL': 'HTTP/1.0'
+}
+
+output = StringIO()
+env['QUERY_STRING'] = 'style=atom'
+hgweb('.', name = 'repo')(env, startrsp)
+print output.getvalue()
+print '---- ERRORS'
+print errors.getvalue()
+
+output = StringIO()
+env['QUERY_STRING'] = 'style=raw'
+hgwebdir({'repo': '.'})(env, startrsp)
+print output.getvalue()
+print '---- ERRORS'
+print errors.getvalue()
+EOF
+
+python request.py | sed "s/http:\/\/127\.0\.0\.1:[0-9]*\//http:\/\/127.0.0.1\//"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-hgweb-no-path-info.out Thu Apr 03 13:21:42 2008 +0200
@@ -0,0 +1,50 @@
+changeset: 0:4cbec7e6f8c4
+tag: tip
+user: Testing
+date: Thu Jan 01 00:00:00 1970 +0000
+summary: test
+
+---- HEADERS
+200 Script output follows
+---- DATA
+[('Content-Type', 'application/atom+xml; charset=ascii')]
+<?xml version="1.0" encoding="ascii"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <!-- Changelog -->
+ <id>http://127.0.0.1/</id>
+ <link rel="self" href="http://127.0.0.1/atom-log"/>
+ <link rel="alternate" href="http://127.0.0.1/"/>
+ <title>repo Changelog</title>
+ <updated>1970-01-01T00:00:00+00:00</updated>
+
+ <entry>
+ <title>test</title>
+ <id>http://www.selenic.com/mercurial/#changeset-4cbec7e6f8c42eb52b6b52670e1f7560ae9a101e</id>
+ <link href="http://127.0.0.1/rev/4cbec7e6f8c42eb52b6b52670e1f7560ae9a101e"/>
+ <author>
+ <name>Testing</name>
+ <email>Testing</email>
+ </author>
+ <updated>1970-01-01T00:00:00+00:00</updated>
+ <published>1970-01-01T00:00:00+00:00</published>
+ <content type="xhtml">
+ <div xmlns="http://www.w3.org/1999/xhtml">
+ <pre xml:space="preserve">test</pre>
+ </div>
+ </content>
+ </entry>
+
+</feed>
+
+---- ERRORS
+
+---- HEADERS
+200 Script output follows
+---- DATA
+[('Content-Type', 'text/plain; charset=ascii')]
+
+repo/
+
+
+---- ERRORS
+