diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -169,20 +169,23 @@ class hgweb(object): req.write(content) del tmpl - return ''.join(content), + return [] 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)) + return [] 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))) + return [] except ErrorResponse, inst: req.respond(inst.code, ctype) - return ''.join(tmpl('error', error=inst.message)), + req.write(tmpl('error', error=inst.message)) + return [] def templater(self, req): diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -89,12 +89,14 @@ class hgwebdir(object): 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 @@ -116,7 +118,8 @@ class hgwebdir(object): 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 +128,13 @@ class hgwebdir(object): # prefixes not found req.respond(HTTP_NOT_FOUND, ctype) - return ''.join(tmpl("notfound", repo=virtual)), + req.write(tmpl("notfound", repo=virtual)) + return [] except ErrorResponse, err: req.respond(err.code, ctype) - return ''.join(tmpl('error', error=err.message or '')), + req.write(tmpl('error', error=err.message or '')) + return [] finally: tmpl = None diff --git a/tests/test-hgweb-no-path-info b/tests/test-hgweb-no-path-info --- a/tests/test-hgweb-no-path-info +++ b/tests/test-hgweb-no-path-info @@ -43,17 +43,15 @@ env = { 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 --git a/tests/test-hgweb-no-path-info.out b/tests/test-hgweb-no-path-info.out --- a/tests/test-hgweb-no-path-info.out +++ b/tests/test-hgweb-no-path-info.out @@ -35,6 +35,7 @@ 200 Script output follows + ---- ERRORS ---- HEADERS @@ -44,5 +45,6 @@ 200 Script output follows repo/ + ---- ERRORS diff --git a/tests/test-hgweb-no-request-uri b/tests/test-hgweb-no-request-uri --- a/tests/test-hgweb-no-request-uri +++ b/tests/test-hgweb-no-request-uri @@ -44,36 +44,32 @@ env = { 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 --git a/tests/test-hgweb-no-request-uri.out b/tests/test-hgweb-no-request-uri.out --- a/tests/test-hgweb-no-request-uri.out +++ b/tests/test-hgweb-no-request-uri.out @@ -35,6 +35,7 @@ 200 Script output follows + ---- ERRORS ---- HEADERS @@ -45,6 +46,7 @@ 200 Script output follows -rw-r--r-- 4 bar + ---- ERRORS ---- HEADERS @@ -54,6 +56,7 @@ 200 Script output follows /repo/ + ---- ERRORS ---- HEADERS @@ -64,5 +67,6 @@ 200 Script output follows -rw-r--r-- 4 bar + ---- ERRORS