diff -r 209577095f20 -r a0e20a5eba3c mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Fri Jan 18 19:53:38 2008 +0100 +++ b/mercurial/hgweb/webcommands.py Fri Jan 18 19:53:38 2008 +0100 @@ -5,8 +5,8 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os -from mercurial import revlog +import os, mimetypes +from mercurial import revlog, util from common import staticfile def log(web, req, tmpl): @@ -15,6 +15,27 @@ else: 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 + + try: + fctx = web.filectx(req) + except revlog.LookupError: + req.write(web.manifest(tmpl, web.changectx(req), path)) + return + + path = fctx.path() + text = fctx.data() + mt = mimetypes.guess_type(path)[0] + if util.binary(text): + mt = mt or 'application/octet-stream' + + req.httphdr(mt, path, len(text)) + req.write(text) + def file(web, req, tmpl): path = web.cleanpath(req.form.get('file', [''])[0]) if path: