[PATCH 2 of 3] hgweb: replace file I/O with util.readfile
Augie Fackler
raf at durin42.com
Thu Jan 14 19:14:59 UTC 2016
On Tue, Jan 12, 2016 at 04:21:02PM -0800, Bryan O'Sullivan wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bryano at fb.com>
> # Date 1452643932 28800
> # Tue Jan 12 16:12:12 2016 -0800
> # Node ID bdda0258d3884e81b9b80ca71669934d237be54c
> # Parent dc4b31f3489f5c7d574c8bf2e1f0d96a0564fd50
> hgweb: replace file I/O with util.readfile
Dropping this one, as it flunks tests (needs a from .. import util,
but also some other stuff I don't have time to debug right now once
that's added.)
>
> diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py
> --- a/mercurial/hgweb/common.py
> +++ b/mercurial/hgweb/common.py
> @@ -146,12 +146,8 @@ def staticfile(directory, fname, req):
> if os.path.exists(path):
> break
> try:
> - os.stat(path)
> ct = mimetypes.guess_type(path)[0] or "text/plain"
> - fp = open(path, 'rb')
> - data = fp.read()
> - fp.close()
> - req.respond(HTTP_OK, ct, body=data)
> + req.respond(HTTP_OK, ct, body=util.readfile(path))
> except TypeError:
> raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename')
> except OSError as err:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list