Mercurial > hg-stable
changeset 5588:083b6e3142a2
churn: avoid division by zero
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 02 Dec 2007 17:04:16 -0600 |
parents | 121f9dbcc236 (current diff) b90b72729a72 (diff) |
children | 9981b6b19ecf |
files | contrib/churn.py mercurial/hgweb/hgweb_mod.py |
diffstat | 21 files changed, 606 insertions(+), 69 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/churn.py Sun Dec 02 16:26:56 2007 -0600 +++ b/contrib/churn.py Sun Dec 02 17:04:16 2007 -0600 @@ -125,6 +125,7 @@ ui.note("rev %d: %d lines by %s\n" % (rev, lines, who)) if progress: + nr_revs = max(nr_revs, 1) if int(100.0*(cur_rev - 1)/nr_revs) < int(100.0*cur_rev/nr_revs): ui.write("%d%%.." % (int(100.0*cur_rev/nr_revs),)) sys.stdout.flush() @@ -144,6 +145,7 @@ return s[0:l] def graph(n, maximum, width, char): + maximum = max(1, maximum) n = int(n * width / float(maximum)) return char * (n) @@ -178,6 +180,8 @@ ordered = stats.items() ordered.sort(lambda x, y: cmp(y[1], x[1])) + if not ordered: + return maximum = ordered[0][1] width = get_tty_width()
--- a/doc/hgrc.5.txt Sun Dec 02 16:26:56 2007 -0600 +++ b/doc/hgrc.5.txt Sun Dec 02 17:04:16 2007 -0600 @@ -17,7 +17,9 @@ Mercurial reads configuration data from several files, if they exist. The names of these files depend on the system on which Mercurial is -installed. +installed. Windows registry keys contain PATH-like strings, every +part must reference a Mercurial.ini file or be a directory where *.rc +files will be read. (Unix) <install-root>/etc/mercurial/hgrc.d/*.rc:: (Unix) <install-root>/etc/mercurial/hgrc:: @@ -29,6 +31,8 @@ (Unix) /etc/mercurial/hgrc.d/*.rc:: (Unix) /etc/mercurial/hgrc:: +(Windows) HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial:: + or:: (Windows) C:\Mercurial\Mercurial.ini:: Per-system configuration files, for the system on which Mercurial is running. Options in these files apply to all Mercurial
--- a/mercurial/hgweb/hgweb_mod.py Sun Dec 02 16:26:56 2007 -0600 +++ b/mercurial/hgweb/hgweb_mod.py Sun Dec 02 17:04:16 2007 -0600 @@ -726,37 +726,21 @@ def rewrite_request(req): '''translate new web interface to traditional format''' - def spliturl(req): - def firstitem(query): - return query.split('&', 1)[0].split(';', 1)[0] - - def normurl(url): - inner = '/'.join([x for x in url.split('/') if x]) - tl = len(url) > 1 and url.endswith('/') and '/' or '' - - return '%s%s%s' % (url.startswith('/') and '/' or '', - inner, tl) - - root = normurl(urllib.unquote(req.env.get('REQUEST_URI', '').split('?', 1)[0])) - pi = normurl(req.env.get('PATH_INFO', '')) - if pi: - # strip leading / - pi = pi[1:] - if pi: - root = root[:root.rfind(pi)] - if req.env.has_key('REPO_NAME'): - rn = req.env['REPO_NAME'] + '/' - root += rn - query = pi[len(rn):] - else: - query = pi - else: - root += '?' - query = firstitem(req.env['QUERY_STRING']) - - return (root, query) - - req.url, query = spliturl(req) + req.url = req.env['SCRIPT_NAME'] + if not req.url.endswith('/'): + req.url += '/' + if req.env.has_key('REPO_NAME'): + req.url += req.env['REPO_NAME'] + '/' + + if req.env.get('PATH_INFO'): + parts = req.env.get('PATH_INFO').strip('/').split('/') + repo_parts = req.env.get('REPO_NAME', '').split('/') + if parts[:len(repo_parts)] == repo_parts: + parts = parts[len(repo_parts):] + query = '/'.join(parts) + else: + query = req.env['QUERY_STRING'].split('&', 1)[0] + query = query.split(';', 1)[0] if req.form.has_key('cmd'): # old style
--- a/mercurial/hgweb/hgwebdir_mod.py Sun Dec 02 16:26:56 2007 -0600 +++ b/mercurial/hgweb/hgwebdir_mod.py Sun Dec 02 17:04:16 2007 -0600 @@ -17,7 +17,7 @@ class hgwebdir(object): def __init__(self, config, parentui=None): def cleannames(items): - return [(util.pconvert(name.strip(os.sep)), path) + return [(util.pconvert(name).strip('/'), path) for name, path in items] self.parentui = parentui @@ -91,15 +91,11 @@ def config(section, name, default=None, untrusted=True): return parentui.config(section, name, default, untrusted) - url = req.env['REQUEST_URI'].split('?')[0] + url = req.env.get('SCRIPT_NAME', '') if not url.endswith('/'): url += '/' - pathinfo = req.env.get('PATH_INFO', '').strip('/') + '/' - base = url[:len(url) - len(pathinfo)] - if not base.endswith('/'): - base += '/' - staticurl = config('web', 'staticurl') or base + 'static/' + staticurl = config('web', 'staticurl') or url + 'static/' if not staticurl.endswith('/'): staticurl += '/' @@ -158,8 +154,10 @@ if u.configbool("web", "hidden", untrusted=True): continue - url = ('/'.join([req.env["REQUEST_URI"].split('?')[0], name]) - .replace("//", "/")) + '/' + parts = [req.env['PATH_INFO'], name] + if req.env['SCRIPT_NAME']: + parts.insert(0, req.env['SCRIPT_NAME']) + url = ('/'.join(parts).replace("//", "/")) + '/' # update time with local timezone try:
--- a/mercurial/hgweb/server.py Sun Dec 02 16:26:56 2007 -0600 +++ b/mercurial/hgweb/server.py Sun Dec 02 17:04:16 2007 -0600 @@ -84,6 +84,7 @@ env['SERVER_NAME'] = self.server.server_name env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_URI'] = self.path + env['SCRIPT_NAME'] = '' env['PATH_INFO'] = path_info env['REMOTE_HOST'] = self.client_address[0] env['REMOTE_ADDR'] = self.client_address[0]
--- a/mercurial/hgweb/wsgicgi.py Sun Dec 02 16:26:56 2007 -0600 +++ b/mercurial/hgweb/wsgicgi.py Sun Dec 02 17:04:16 2007 -0600 @@ -16,6 +16,7 @@ util.set_binary(sys.stdout) environ = dict(os.environ.items()) + environ.setdefault('PATH_INFO', '') environ['wsgi.input'] = sys.stdin environ['wsgi.errors'] = sys.stderr environ['wsgi.version'] = (1, 0) @@ -61,13 +62,4 @@ headers_set[:] = [status, response_headers] return write - result = application(environ, start_response) - try: - for data in result: - if data: # don't send headers until body appears - write(data) - if not headers_sent: - write('') # send headers now if body was empty - finally: - if hasattr(result,'close'): - result.close() + application(environ, start_response)
--- a/mercurial/patch.py Sun Dec 02 16:26:56 2007 -0600 +++ b/mercurial/patch.py Sun Dec 02 17:04:16 2007 -0600 @@ -885,6 +885,19 @@ dopatch = True gitworkdone = False + def getpatchfile(afile, bfile, hunk): + try: + if sourcefile: + targetfile = patchfile(ui, sourcefile) + else: + targetfile = selectfile(afile, bfile, hunk, + strip, reverse) + targetfile = patchfile(ui, targetfile) + return targetfile + except PatchError, err: + ui.warn(str(err) + '\n') + return None + while True: newfile = False x = lr.readline() @@ -912,22 +925,20 @@ continue hunknum += 1 if not current_file: - if sourcefile: - current_file = patchfile(ui, sourcefile) - else: - current_file = selectfile(afile, bfile, current_hunk, - strip, reverse) - current_file = patchfile(ui, current_file) + current_file = getpatchfile(afile, bfile, current_hunk) + if not current_file: + current_file, current_hunk = None, None + rejects += 1 + continue elif state == BFILE and x.startswith('GIT binary patch'): current_hunk = binhunk(changed[bfile[2:]][1]) + hunknum += 1 if not current_file: - if sourcefile: - current_file = patchfile(ui, sourcefile) - else: - current_file = selectfile(afile, bfile, current_hunk, - strip, reverse) - current_file = patchfile(ui, current_file) - hunknum += 1 + current_file = getpatchfile(afile, bfile, current_hunk) + if not current_file: + current_file, current_hunk = None, None + rejects += 1 + continue current_hunk.extract(fp) elif x.startswith('diff --git'): # check for git diff, scanning the whole patch file if needed
--- a/mercurial/util_win32.py Sun Dec 02 16:26:56 2007 -0600 +++ b/mercurial/util_win32.py Sun Dec 02 17:04:16 2007 -0600 @@ -16,6 +16,7 @@ from i18n import _ import errno, os, pywintypes, win32con, win32file, win32process import cStringIO, winerror +import osutil from win32com.shell import shell,shellcon class WinError: @@ -179,6 +180,20 @@ def system_rcpath_win32(): '''return default os-specific hgrc search path''' + try: + value = win32api.RegQueryValue( + win32con.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Mercurial') + rcpath = [] + for p in value.split(os.pathsep): + if p.lower().endswith('mercurial.ini'): + rcpath.append(p) + elif os.path.isdir(p): + for f, kind in osutil.listdir(p): + if f.endswith('.rc'): + rcpath.append(os.path.join(p, f)) + return rcpath + except pywintypes.error: + pass proc = win32api.GetCurrentProcess() try: # This will fail on windows < NT
--- a/tests/test-hgweb Sun Dec 02 16:26:56 2007 -0600 +++ b/tests/test-hgweb Sun Dec 02 17:04:16 2007 -0600 @@ -1,4 +1,5 @@ #!/bin/sh +# Some tests for hgweb. Tests static files, plain files and different 404's. hg init test cd test
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-hgweb-no-request-uri Sun Dec 02 17:04:16 2007 -0600 @@ -0,0 +1,77 @@ +#!/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['PATH_INFO'] = '/' +env['QUERY_STRING'] = 'style=atom' +hgweb('.', name = 'repo')(env, startrsp) +print output.getvalue() +print '---- ERRORS' +print errors.getvalue() + +output = StringIO() +env['PATH_INFO'] = '/file/tip/' +env['QUERY_STRING'] = 'style=raw' +hgweb('.', name = 'repo')(env, startrsp) +print output.getvalue() +print '---- ERRORS' +print errors.getvalue() + +output = StringIO() +env['PATH_INFO'] = '/' +env['QUERY_STRING'] = 'style=raw' +hgwebdir({'repo': '.'})(env, startrsp) +print output.getvalue() +print '---- ERRORS' +print errors.getvalue() + +output = StringIO() +env['PATH_INFO'] = '/repo/file/tip/' +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-request-uri.out Sun Dec 02 17:04:16 2007 -0600 @@ -0,0 +1,72 @@ +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')] + +-rw-r--r-- 4 bar + + + +---- ERRORS + +---- HEADERS +200 Script output follows +---- DATA +[('content-type', 'text/plain; charset=ascii')] + +/repo/ + + +---- ERRORS + +---- HEADERS +200 Script output follows +---- DATA +[('content-type', 'text/plain; charset=ascii')] + +-rw-r--r-- 4 bar + + + +---- ERRORS +
--- a/tests/test-hgwebdir Sun Dec 02 16:26:56 2007 -0600 +++ b/tests/test-hgwebdir Sun Dec 02 17:04:16 2007 -0600 @@ -1,4 +1,6 @@ #!/bin/sh +# Tests some basic hgwebdir functionality. Tests setting up paths and +# collection, different forms of 404s and the subdirectory support. mkdir webdir cd webdir @@ -39,17 +41,37 @@ echo % should give a 404 - repo is not published "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/c/file/tip/c?style=raw' +cat > paths.conf <<EOF +[paths] +t/a/=$root/a +b=$root/b +EOF + +hg serve -p $HGPORT1 -d --pid-file=hg.pid --webdir-conf paths.conf \ + -A access-paths.log -E error-paths.log +cat hg.pid >> $DAEMON_PIDS + +echo % should succeed, slashy names +"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/?style=raw' +"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t?style=raw' +"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t/?style=raw' +"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t/a?style=atom' \ + | sed "s/http:\/\/[^/]*\//http:\/\/127.0.0.1\//" +"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t/a/?style=atom' \ + | sed "s/http:\/\/[^/]*\//http:\/\/127.0.0.1\//" +"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t/a/file/tip/a?style=raw' + cat > collections.conf <<EOF [collections] $root=$root EOF -hg serve -p $HGPORT1 -d --pid-file=hg.pid --webdir-conf collections.conf \ +hg serve -p $HGPORT2 -d --pid-file=hg.pid --webdir-conf collections.conf \ -A access-collections.log -E error-collections.log cat hg.pid >> $DAEMON_PIDS echo % should succeed -"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/?style=raw' -"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/a/file/tip/a?style=raw' -"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/b/file/tip/b?style=raw' -"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/c/file/tip/c?style=raw' +"$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/?style=raw' +"$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/a/file/tip/a?style=raw' +"$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/b/file/tip/b?style=raw' +"$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/c/file/tip/c?style=raw'
--- a/tests/test-hgwebdir.out Sun Dec 02 16:26:56 2007 -0600 +++ b/tests/test-hgwebdir.out Sun Dec 02 17:04:16 2007 -0600 @@ -24,6 +24,84 @@ error: repository c not found +% should succeed, slashy names +200 Script output follows + + +/b/ +/t/a/ + +200 Script output follows + + +/t/a/ + +200 Script output follows + + +/t/a/ + +200 Script output follows + +<?xml version="1.0" encoding="ascii"?> +<feed xmlns="http://127.0.0.1/2005/Atom"> + <!-- Changelog --> + <id>http://127.0.0.1/t/a/</id> + <link rel="self" href="http://127.0.0.1/t/a/atom-log"/> + <link rel="alternate" href="http://127.0.0.1/t/a/"/> + <title>t/a Changelog</title> + <updated>1970-01-01T00:00:01+00:00</updated> + + <entry> + <title>a</title> + <id>http://127.0.0.1/mercurial/#changeset-8580ff50825a50c8f716709acdf8de0deddcd6ab</id> + <link href="http://127.0.0.1/t/a/rev/8580ff50825a50c8f716709acdf8de0deddcd6ab"/> + <author> + <name>test</name> + <email>test</email> + </author> + <updated>1970-01-01T00:00:01+00:00</updated> + <published>1970-01-01T00:00:01+00:00</published> + <content type="xhtml"> + <div xmlns="http://127.0.0.1/1999/xhtml"> + <pre xml:space="preserve">a</pre> + </div> + </content> + </entry> + +</feed> +200 Script output follows + +<?xml version="1.0" encoding="ascii"?> +<feed xmlns="http://127.0.0.1/2005/Atom"> + <!-- Changelog --> + <id>http://127.0.0.1/t/a/</id> + <link rel="self" href="http://127.0.0.1/t/a/atom-log"/> + <link rel="alternate" href="http://127.0.0.1/t/a/"/> + <title>t/a Changelog</title> + <updated>1970-01-01T00:00:01+00:00</updated> + + <entry> + <title>a</title> + <id>http://127.0.0.1/mercurial/#changeset-8580ff50825a50c8f716709acdf8de0deddcd6ab</id> + <link href="http://127.0.0.1/t/a/rev/8580ff50825a50c8f716709acdf8de0deddcd6ab"/> + <author> + <name>test</name> + <email>test</email> + </author> + <updated>1970-01-01T00:00:01+00:00</updated> + <published>1970-01-01T00:00:01+00:00</published> + <content type="xhtml"> + <div xmlns="http://127.0.0.1/1999/xhtml"> + <pre xml:space="preserve">a</pre> + </div> + </content> + </entry> + +</feed> +200 Script output follows + +a % should succeed 200 Script output follows
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-mq-missingfiles Sun Dec 02 17:04:16 2007 -0600 @@ -0,0 +1,69 @@ +#!/bin/sh + +# Test issue835: +# qpush fails immediately when patching a missing file, but +# remaining added files are still created empty which will +# trick a future qrefresh. + +cat > writelines.py <<EOF +import sys +path = sys.argv[1] +args = sys.argv[2:] +assert (len(args) % 2) == 0 + +f = file(path, 'wb') +for i in xrange(len(args)/2): + count, s = args[2*i:2*i+2] + count = int(count) + s = s.decode('string_escape') + f.write(s*count) +f.close() + +EOF + +echo "[extensions]" >> $HGRCPATH +echo "mq=" >> $HGRCPATH + +hg init normal +cd normal +python ../writelines.py b 10 'a\n' +hg ci -Am addb +echo a > a +python ../writelines.py b 2 'b\n' 10 'a\n' 2 'c\n' +echo c > c +hg add a c +hg qnew -f changeb +hg qpop +hg rm b +hg ci -Am rmb +echo % push patch with missing target +hg qpush +echo % display added files +cat a +cat c +cd .. + + +echo "[diff]" >> $HGRCPATH +echo "git=1" >> $HGRCPATH + +hg init git +cd git +python ../writelines.py b 1 '\x00' +hg ci -Am addb +echo a > a +python ../writelines.py b 1 '\x01' 1 '\x00' +echo c > c +hg add a c +hg qnew -f changeb +hg qpop +hg rm b +hg ci -Am rmb +echo % push git patch with missing target +hg qpush 2>&1 | sed -e 's/b:.*/b: No such file or directory/' +hg st +echo % display added files +cat a +cat c +cd .. +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-mq-missingfiles.out Sun Dec 02 17:04:16 2007 -0600 @@ -0,0 +1,25 @@ +adding b +Patch queue now empty +% push patch with missing target +applying changeb +unable to find b or b for patching +unable to find b or b for patching +patch failed, unable to continue (try -v) +patch failed, rejects left in working dir +Errors during apply, please fix and refresh changeb +% display added files +a +c +adding b +Patch queue now empty +% push git patch with missing target +applying changeb +unable to find b or b for patching +patch failed, unable to continue (try -v) +b: No such file or directory +b not tracked! +patch failed, rejects left in working dir +Errors during apply, please fix and refresh changeb +% display added files +a +c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-newcgi Sun Dec 02 17:04:16 2007 -0600 @@ -0,0 +1,91 @@ +#!/bin/sh +# This tests if CGI files from after d0db3462d568 but +# before d74fc8dec2b4 still work. + +hg init test + +cat >hgweb.cgi <<HGWEB +#!/usr/bin/env python +# +# An example CGI script to use hgweb, edit as necessary + +import cgitb +cgitb.enable() + +from mercurial import demandimport; demandimport.enable() +from mercurial.hgweb import hgweb +from mercurial.hgweb import wsgicgi +from mercurial.hgweb.request import wsgiapplication + +def make_web_app(): + return hgweb("test", "Empty test repository") + +wsgicgi.launch(wsgiapplication(make_web_app)) +HGWEB +chmod 755 hgweb.cgi + +cat >hgweb.config <<HGWEBDIRCONF +[paths] +test = test +HGWEBDIRCONF + +cat >hgwebdir.cgi <<HGWEBDIR +#!/usr/bin/env python +# +# An example CGI script to export multiple hgweb repos, edit as necessary + +import cgitb +cgitb.enable() + +from mercurial import demandimport; demandimport.enable() +from mercurial.hgweb import hgwebdir +from mercurial.hgweb import wsgicgi +from mercurial.hgweb.request import wsgiapplication + +def make_web_app(): + return hgwebdir("hgweb.config") + +wsgicgi.launch(wsgiapplication(make_web_app)) +HGWEBDIR +chmod 755 hgwebdir.cgi + +DOCUMENT_ROOT="/var/www/hg"; export DOCUMENT_ROOT +GATEWAY_INTERFACE="CGI/1.1"; export GATEWAY_INTERFACE +HTTP_ACCEPT="text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; export HTTP_ACCEPT +HTTP_ACCEPT_CHARSET="ISO-8859-1,utf-8;q=0.7,*;q=0.7"; export HTTP_ACCEPT_CHARSET +HTTP_ACCEPT_ENCODING="gzip,deflate"; export HTTP_ACCEPT_ENCODING +HTTP_ACCEPT_LANGUAGE="en-us,en;q=0.5"; export HTTP_ACCEPT_LANGUAGE +HTTP_CACHE_CONTROL="max-age=0"; export HTTP_CACHE_CONTROL +HTTP_CONNECTION="keep-alive"; export HTTP_CONNECTION +HTTP_HOST="hg.omnifarious.org"; export HTTP_HOST +HTTP_KEEP_ALIVE="300"; export HTTP_KEEP_ALIVE +HTTP_USER_AGENT="Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.4) Gecko/20060608 Ubuntu/dapper-security Firefox/1.5.0.4"; export HTTP_USER_AGENT +PATH_INFO="/"; export PATH_INFO +PATH_TRANSLATED="/var/www/hg/index.html"; export PATH_TRANSLATED +QUERY_STRING=""; export QUERY_STRING +REMOTE_ADDR="127.0.0.2"; export REMOTE_ADDR +REMOTE_PORT="44703"; export REMOTE_PORT +REQUEST_METHOD="GET"; export REQUEST_METHOD +REQUEST_URI="/test/"; export REQUEST_URI +SCRIPT_FILENAME="/home/hopper/hg_public/test.cgi"; export SCRIPT_FILENAME +SCRIPT_NAME="/test"; export SCRIPT_NAME +SCRIPT_URI="http://hg.omnifarious.org/test/"; export SCRIPT_URI +SCRIPT_URL="/test/"; export SCRIPT_URL +SERVER_ADDR="127.0.0.1"; export SERVER_ADDR +SERVER_ADMIN="eric@localhost"; export SERVER_ADMIN +SERVER_NAME="hg.omnifarious.org"; export SERVER_NAME +SERVER_PORT="80"; export SERVER_PORT +SERVER_PROTOCOL="HTTP/1.1"; export SERVER_PROTOCOL +SERVER_SIGNATURE="<address>Apache/2.0.53 (Fedora) Server at hg.omnifarious.org Port 80</address>\; export SERVER_SIGNATURE +" +SERVER_SOFTWARE="Apache/2.0.53 (Fedora)"; export SERVER_SOFTWARE +python hgweb.cgi >page1 2>&1 ; echo $? +python hgwebdir.cgi >page2 2>&1 ; echo $? +PATH_INFO="/test/" +PATH_TRANSLATED="/var/something/test.cgi" +REQUEST_URI="/test/test/" +SCRIPT_URI="http://hg.omnifarious.org/test/test/" +SCRIPT_URL="/test/test/" +python hgwebdir.cgi >page3 2>&1 ; echo $? +fgrep -i error page1 page2 page3 && exit 1 +exit 0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-newcgi.out Sun Dec 02 17:04:16 2007 -0600 @@ -0,0 +1,3 @@ +0 +0 +0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-newercgi Sun Dec 02 17:04:16 2007 -0600 @@ -0,0 +1,84 @@ +#!/bin/sh +# This is a rudimentary test of the CGI files as of d74fc8dec2b4. + +hg init test + +cat >hgweb.cgi <<HGWEB +#!/usr/bin/env python +# +# An example CGI script to use hgweb, edit as necessary + +import cgitb +cgitb.enable() + +from mercurial import demandimport; demandimport.enable() +from mercurial.hgweb import hgweb +from mercurial.hgweb import wsgicgi + +application = hgweb("test", "Empty test repository") +wsgicgi.launch(application) +HGWEB +chmod 755 hgweb.cgi + +cat >hgweb.config <<HGWEBDIRCONF +[paths] +test = test +HGWEBDIRCONF + +cat >hgwebdir.cgi <<HGWEBDIR +#!/usr/bin/env python +# +# An example CGI script to export multiple hgweb repos, edit as necessary + +import cgitb +cgitb.enable() + +from mercurial import demandimport; demandimport.enable() +from mercurial.hgweb import hgwebdir +from mercurial.hgweb import wsgicgi + +application = hgwebdir("hgweb.config") +wsgicgi.launch(application) +HGWEBDIR +chmod 755 hgwebdir.cgi + +DOCUMENT_ROOT="/var/www/hg"; export DOCUMENT_ROOT +GATEWAY_INTERFACE="CGI/1.1"; export GATEWAY_INTERFACE +HTTP_ACCEPT="text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; export HTTP_ACCEPT +HTTP_ACCEPT_CHARSET="ISO-8859-1,utf-8;q=0.7,*;q=0.7"; export HTTP_ACCEPT_CHARSET +HTTP_ACCEPT_ENCODING="gzip,deflate"; export HTTP_ACCEPT_ENCODING +HTTP_ACCEPT_LANGUAGE="en-us,en;q=0.5"; export HTTP_ACCEPT_LANGUAGE +HTTP_CACHE_CONTROL="max-age=0"; export HTTP_CACHE_CONTROL +HTTP_CONNECTION="keep-alive"; export HTTP_CONNECTION +HTTP_HOST="hg.omnifarious.org"; export HTTP_HOST +HTTP_KEEP_ALIVE="300"; export HTTP_KEEP_ALIVE +HTTP_USER_AGENT="Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.4) Gecko/20060608 Ubuntu/dapper-security Firefox/1.5.0.4"; export HTTP_USER_AGENT +PATH_INFO="/"; export PATH_INFO +PATH_TRANSLATED="/var/www/hg/index.html"; export PATH_TRANSLATED +QUERY_STRING=""; export QUERY_STRING +REMOTE_ADDR="127.0.0.2"; export REMOTE_ADDR +REMOTE_PORT="44703"; export REMOTE_PORT +REQUEST_METHOD="GET"; export REQUEST_METHOD +REQUEST_URI="/test/"; export REQUEST_URI +SCRIPT_FILENAME="/home/hopper/hg_public/test.cgi"; export SCRIPT_FILENAME +SCRIPT_NAME="/test"; export SCRIPT_NAME +SCRIPT_URI="http://hg.omnifarious.org/test/"; export SCRIPT_URI +SCRIPT_URL="/test/"; export SCRIPT_URL +SERVER_ADDR="127.0.0.1"; export SERVER_ADDR +SERVER_ADMIN="eric@localhost"; export SERVER_ADMIN +SERVER_NAME="hg.omnifarious.org"; export SERVER_NAME +SERVER_PORT="80"; export SERVER_PORT +SERVER_PROTOCOL="HTTP/1.1"; export SERVER_PROTOCOL +SERVER_SIGNATURE="<address>Apache/2.0.53 (Fedora) Server at hg.omnifarious.org Port 80</address>\; export SERVER_SIGNATURE +" +SERVER_SOFTWARE="Apache/2.0.53 (Fedora)"; export SERVER_SOFTWARE +python hgweb.cgi >page1 2>&1 ; echo $? +python hgwebdir.cgi >page2 2>&1 ; echo $? +PATH_INFO="/test/" +PATH_TRANSLATED="/var/something/test.cgi" +REQUEST_URI="/test/test/" +SCRIPT_URI="http://hg.omnifarious.org/test/test/" +SCRIPT_URL="/test/test/" +python hgwebdir.cgi >page3 2>&1 ; echo $? +fgrep -i error page1 page2 page3 && exit 1 +exit 0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-newercgi.out Sun Dec 02 17:04:16 2007 -0600 @@ -0,0 +1,3 @@ +0 +0 +0
--- a/tests/test-non-interactive-wsgi Sun Dec 02 16:26:56 2007 -0600 +++ b/tests/test-non-interactive-wsgi Sun Dec 02 17:04:16 2007 -0600 @@ -1,4 +1,6 @@ #!/bin/sh +# Tests if hgweb can run without touching sys.stdin, as is required +# by the WSGI standard and strictly implemented by mod_wsgi. mkdir repo cd repo