Page MenuHomePhabricator

dirstate-v2: Enforce data size read from the docket file
ClosedPublic

Authored by SimonSapin on Jul 12 2021, 5:10 PM.

Details

Summary

The data file may not be shorter than its size given by the docket.
It may be longer, but additional data is ignored.

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

SimonSapin created this revision.Jul 12 2021, 5:10 PM
baymax updated this revision to Diff 29219.Jul 12 2021, 6:39 PM

✅ refresh by Heptapod after a successful CI run (🐙 💚)

Alphare accepted this revision.Jul 13 2021, 11:03 AM
This revision is now accepted and ready to land.Jul 13 2021, 11:03 AM
SimonSapin updated this revision to Diff 29236.Jul 13 2021, 3:50 PM

Either I am missing something or we could so something much simpler here.

mercurial/dirstatemap.py
637–643

Why dont' we simply ready docket.data_size data from disk ? instead of doing later filtering ?

SimonSapin added inline comments.Jul 16 2021, 8:13 AM
mercurial/dirstatemap.py
637–643

Yeah that should work, I didn’t think of that. I went with doing the slicing on the Rust side because slicing a Python bytes object allocates a new one and copies. I don’t know how that will work when we use mmap. It’ll probably involve a memoryview?

baymax updated this revision to Diff 29607.Jul 20 2021, 3:41 PM

✅ refresh by Heptapod after a successful CI run (🐙 💚)