Page MenuHomePhabricator

mmap: add a size argument to mmapread
ClosedPublic

Authored by marmoute on Tue, Jan 7, 6:27 AM.

Details

Summary

With this argument, we can control the size of the mmap created. (previously it
was always the whole file.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

marmoute created this revision.Tue, Jan 7, 6:27 AM
mharbison72 added inline comments.
mercurial/util.py
419–422

Why does an explicit size of 0 bail with an empty buffer, but an implicit size 0 proceed?

marmoute added inline comments.Tue, Jan 7, 1:20 PM
mercurial/util.py
419–422

passing 0 in mmap.mmap(fd, 0, access=mmap.ACCESS_READ) get you "all the byte you can eat". That's is not 0 sized mmap.

The size argument for util.mmapread is (after this patch). If size is None "all you can eat". if size is specified: provided exactly that amount of bytes.

durin42 added a subscriber: durin42.Wed, Jan 8, 2:55 PM
durin42 added inline comments.
mercurial/util.py
419–422

This merits a comment. I'll add one in flight.

This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.