This is an archive of the discontinued Mercurial Phabricator instance.

pure-parsers: document index class constants
ClosedPublic

Authored by Alphare on Mar 4 2021, 3:31 AM.

Details

Summary

This also adds the big endian prefix > to make the constants truly
platform-independent, even if no issue with this has been reported in the wild.

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

Alphare created this revision.Mar 4 2021, 3:31 AM
pulkit accepted this revision.Mar 4 2021, 3:57 AM
This revision is now accepted and ready to land.Mar 4 2021, 3:57 AM
SimonSapin added inline comments.
mercurial/pure/parsers.py
48–49

This description isn’t factually wrong, but wouldn’t it be a serious bug if the on-disk format ends up varying across different platforms?

SimonSapin added inline comments.Mar 4 2021, 6:22 AM
mercurial/pure/parsers.py
48–49

Correction: since index_format starts with >, it opts in both to big-endian and to "stardard sizes" so index_size is in fact platform-independent. See docs in https://docs.python.org/3/library/struct.html#format-characters

Maybe > should be added to the format string for big_int_size and int_size as well, just to be safe.

Alphare added inline comments.Mar 4 2021, 10:02 AM
mercurial/pure/parsers.py
48–49

Thanks for the catch, I'll add > to the other format strings

Alphare edited the summary of this revision. (Show Details)Mar 4 2021, 10:10 AM
Alphare updated this revision to Diff 26080.
pulkit accepted this revision.Mar 5 2021, 3:37 AM
This revision was automatically updated to reflect the committed changes.