[PATCH 3 of 3] revlog: read index data using mmap

Yuya Nishihara yuya at tcha.org
Wed Oct 5 06:50:33 EDT 2016


On Tue, 4 Oct 2016 15:59:45 +0100, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1475550701 -3600
> #      Tue Oct 04 04:11:41 2016 +0100
> # Node ID 99e7b0589b916b83d825882e907dd79082f4a2d7
> # Parent  5ebdfd4ffbedbfe66b7a36cbd06b1e8e624ae7ad
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 99e7b0589b91
> revlog: read index data using mmap

What happens if revlog is stripped? Using mmap would introduce more error
modes we'll need to test.

FWIW, I know Python crashes if mmapped file is truncated to be empty.

with open('foo', 'wb') as fp:
    fp.write('a')
fp = open('foo', 'rb')
s = mmap.mmap(fp.fileno(), 0, access=mmap.ACCESS_READ)
with open('foo', 'wb') as fp2:
    pass  # truncate
print(s[0])


More information about the Mercurial-devel mailing list