--- a/mercurial/hgweb/webcommands.py Mon Jan 28 14:58:03 2008 +0100
+++ b/mercurial/hgweb/webcommands.py Mon Jan 28 15:10:17 2008 +0100
@@ -20,21 +20,19 @@
def log(web, req, tmpl):
if 'file' in req.form and req.form['file'][0]:
- filelog(web, req, tmpl)
+ return filelog(web, req, tmpl)
else:
- changelog(web, req, tmpl)
+ return changelog(web, req, tmpl)
def rawfile(web, req, tmpl):
path = web.cleanpath(req.form.get('file', [''])[0])
if not path:
- req.write(web.manifest(tmpl, web.changectx(req), path))
- return
+ return web.manifest(tmpl, web.changectx(req), path)
try:
fctx = web.filectx(req)
except revlog.LookupError:
- req.write(web.manifest(tmpl, web.changectx(req), path))
- return
+ return web.manifest(tmpl, web.changectx(req), path)
path = fctx.path()
text = fctx.data()
@@ -43,18 +41,17 @@
mt = mt or 'application/octet-stream'
req.httphdr(mt, path, len(text))
- req.write(text)
+ return [text]
def file(web, req, tmpl):
path = web.cleanpath(req.form.get('file', [''])[0])
if path:
try:
- req.write(web.filerevision(tmpl, web.filectx(req)))
- return
+ return web.filerevision(tmpl, web.filectx(req))
except revlog.LookupError:
pass
- req.write(web.manifest(tmpl, web.changectx(req), path))
+ return web.manifest(tmpl, web.changectx(req), path)
def changelog(web, req, tmpl, shortlog = False):
if 'node' in req.form:
@@ -67,39 +64,38 @@
try:
ctx = web.repo.changectx(hi)
except hg.RepoError:
- req.write(web.search(tmpl, hi)) # XXX redirect to 404 page?
- return
+ return web.search(tmpl, hi) # XXX redirect to 404 page?
- req.write(web.changelog(tmpl, ctx, shortlog = shortlog))
+ return web.changelog(tmpl, ctx, shortlog = shortlog)
def shortlog(web, req, tmpl):
- changelog(web, req, tmpl, shortlog = True)
+ return changelog(web, req, tmpl, shortlog = True)
def changeset(web, req, tmpl):
- req.write(web.changeset(tmpl, web.changectx(req)))
+ return web.changeset(tmpl, web.changectx(req))
rev = changeset
def manifest(web, req, tmpl):
- req.write(web.manifest(tmpl, web.changectx(req),
- web.cleanpath(req.form['path'][0])))
+ return web.manifest(tmpl, web.changectx(req),
+ web.cleanpath(req.form['path'][0]))
def tags(web, req, tmpl):
- req.write(web.tags(tmpl))
+ return web.tags(tmpl)
def summary(web, req, tmpl):
- req.write(web.summary(tmpl))
+ return web.summary(tmpl)
def filediff(web, req, tmpl):
- req.write(web.filediff(tmpl, web.filectx(req)))
+ return web.filediff(tmpl, web.filectx(req))
diff = filediff
def annotate(web, req, tmpl):
- req.write(web.fileannotate(tmpl, web.filectx(req)))
+ return web.fileannotate(tmpl, web.filectx(req))
def filelog(web, req, tmpl):
- req.write(web.filelog(tmpl, web.filectx(req)))
+ return web.filelog(tmpl, web.filectx(req))
def archive(web, req, tmpl):
type_ = req.form['type'][0]
@@ -107,7 +103,7 @@
if (type_ in web.archives and (type_ in allowed or
web.configbool("web", "allow" + type_, False))):
web.archive(tmpl, req, req.form['node'][0], type_)
- return
+ return []
raise ErrorResponse(400, 'Unsupported archive type: %s' % type_)
@@ -118,4 +114,4 @@
static = web.config("web", "static",
os.path.join(web.templatepath, "static"),
untrusted=False)
- req.write(staticfile(static, fname, req))
+ return [staticfile(static, fname, req)]