# HG changeset patch # User Dirkjan Ochtman # Date 1214992953 -7200 # Node ID 943f066c0d58763d3bffa6333e8da31988e02fa0 # Parent 4879468fa28f48b36bb2860ba1c92022b1529c48 Backed out changeset 4879468fa28f (incorrect Content-Length on Windows) diff -r 4879468fa28f -r 943f066c0d58 mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py Sun Jun 29 22:36:18 2008 +0200 +++ b/mercurial/hgweb/hgweb_mod.py Wed Jul 02 12:02:33 2008 +0200 @@ -169,20 +169,20 @@ req.write(content) del tmpl - return ''.join(content), + return req except revlog.LookupError, err: req.respond(HTTP_NOT_FOUND, ctype) msg = str(err) if 'manifest' not in msg: msg = 'revision not found: %s' % err.name - return ''.join(tmpl('error', error=msg)), + req.write(tmpl('error', error=msg)) except (RepoError, revlog.RevlogError), inst: req.respond(HTTP_SERVER_ERROR, ctype) - return ''.join(tmpl('error', error=str(inst))), + req.write(tmpl('error', error=str(inst))) except ErrorResponse, inst: req.respond(inst.code, ctype) - return ''.join(tmpl('error', error=inst.message)), + req.write(tmpl('error', error=inst.message)) def templater(self, req): diff -r 4879468fa28f -r 943f066c0d58 mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py Sun Jun 29 22:36:18 2008 +0200 +++ b/mercurial/hgweb/hgwebdir_mod.py Wed Jul 02 12:02:33 2008 +0200 @@ -70,7 +70,8 @@ def __call__(self, env, respond): req = wsgirequest(env, respond) - return self.run_wsgi(req) + self.run_wsgi(req) + return req def run_wsgi(self, req): @@ -89,12 +90,14 @@ fname = virtual[7:] else: fname = req.form['static'][0] - return staticfile(static, fname, req), + req.write(staticfile(static, fname, req)) + return # top-level index elif not virtual: req.respond(HTTP_OK, ctype) - return ''.join(self.makeindex(req, tmpl)), + req.write(self.makeindex(req, tmpl)) + return # nested indexes and hgwebs @@ -105,7 +108,8 @@ req.env['REPO_NAME'] = virtual try: repo = hg.repository(self.parentui, real) - return hgweb(repo).run_wsgi(req) + hgweb(repo).run_wsgi(req) + return except IOError, inst: msg = inst.strerror raise ErrorResponse(HTTP_SERVER_ERROR, msg) @@ -116,7 +120,8 @@ subdir = virtual + '/' if [r for r in repos if r.startswith(subdir)]: req.respond(HTTP_OK, ctype) - return ''.join(self.makeindex(req, tmpl, subdir)), + req.write(self.makeindex(req, tmpl, subdir)) + return up = virtual.rfind('/') if up < 0: @@ -125,11 +130,11 @@ # prefixes not found req.respond(HTTP_NOT_FOUND, ctype) - return ''.join(tmpl("notfound", repo=virtual)), + req.write(tmpl("notfound", repo=virtual)) except ErrorResponse, err: req.respond(err.code, ctype) - return ''.join(tmpl('error', error=err.message or '')), + req.write(tmpl('error', error=err.message or '')) finally: tmpl = None diff -r 4879468fa28f -r 943f066c0d58 tests/test-hgweb-no-path-info --- a/tests/test-hgweb-no-path-info Sun Jun 29 22:36:18 2008 +0200 +++ b/tests/test-hgweb-no-path-info Wed Jul 02 12:02:33 2008 +0200 @@ -43,17 +43,15 @@ output = StringIO() env['QUERY_STRING'] = 'style=atom' -content = hgweb('.', name = 'repo')(env, startrsp) -sys.stdout.write(output.getvalue()) -sys.stdout.write(''.join(content)) +hgweb('.', name = 'repo')(env, startrsp) +print output.getvalue() print '---- ERRORS' print errors.getvalue() output = StringIO() env['QUERY_STRING'] = 'style=raw' -content = hgwebdir({'repo': '.'})(env, startrsp) -sys.stdout.write(output.getvalue()) -sys.stdout.write(''.join(content)) +hgwebdir({'repo': '.'})(env, startrsp) +print output.getvalue() print '---- ERRORS' print errors.getvalue() EOF diff -r 4879468fa28f -r 943f066c0d58 tests/test-hgweb-no-path-info.out --- a/tests/test-hgweb-no-path-info.out Sun Jun 29 22:36:18 2008 +0200 +++ b/tests/test-hgweb-no-path-info.out Wed Jul 02 12:02:33 2008 +0200 @@ -35,6 +35,7 @@ + ---- ERRORS ---- HEADERS @@ -44,5 +45,6 @@ repo/ + ---- ERRORS diff -r 4879468fa28f -r 943f066c0d58 tests/test-hgweb-no-request-uri --- a/tests/test-hgweb-no-request-uri Sun Jun 29 22:36:18 2008 +0200 +++ b/tests/test-hgweb-no-request-uri Wed Jul 02 12:02:33 2008 +0200 @@ -44,36 +44,32 @@ output = StringIO() env['PATH_INFO'] = '/' env['QUERY_STRING'] = 'style=atom' -content = hgweb('.', name = 'repo')(env, startrsp) -sys.stdout.write(output.getvalue()) -sys.stdout.write(''.join(content)) +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' -content = hgweb('.', name = 'repo')(env, startrsp) -sys.stdout.write(output.getvalue()) -sys.stdout.write(''.join(content)) +hgweb('.', name = 'repo')(env, startrsp) +print output.getvalue() print '---- ERRORS' print errors.getvalue() output = StringIO() env['PATH_INFO'] = '/' env['QUERY_STRING'] = 'style=raw' -content = hgwebdir({'repo': '.'})(env, startrsp) -sys.stdout.write(output.getvalue()) -sys.stdout.write(''.join(content)) +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' -content = hgwebdir({'repo': '.'})(env, startrsp) -sys.stdout.write(output.getvalue()) -sys.stdout.write(''.join(content)) +hgwebdir({'repo': '.'})(env, startrsp) +print output.getvalue() print '---- ERRORS' print errors.getvalue() EOF diff -r 4879468fa28f -r 943f066c0d58 tests/test-hgweb-no-request-uri.out --- a/tests/test-hgweb-no-request-uri.out Sun Jun 29 22:36:18 2008 +0200 +++ b/tests/test-hgweb-no-request-uri.out Wed Jul 02 12:02:33 2008 +0200 @@ -35,6 +35,7 @@ + ---- ERRORS ---- HEADERS @@ -45,6 +46,7 @@ -rw-r--r-- 4 bar + ---- ERRORS ---- HEADERS @@ -54,6 +56,7 @@ /repo/ + ---- ERRORS ---- HEADERS @@ -64,5 +67,6 @@ -rw-r--r-- 4 bar + ---- ERRORS