# HG changeset patch # User Simon Sapin # Date 1633690644 -7200 # Node ID 6e01bcd111d26c4c131315888adc9d87b45a4fe4 # Parent 77fc340acad73a3d0d21094f5f8920a942a1c596 dirstate-v2: Swap the order of size and mtime on disk This makes the dirstate-v2 file format match dirstate-v1 for the order of `mode`, `size`, and `mtime`. This order does not matter as long as these components are handled through named fields/attributes in code, but in a few places we still have tuples so having the same order everywhere might help avoid a bug that might not be obvious since those components have the same type. Differential Revision: https://phab.mercurial-scm.org/D11620 diff -r 77fc340acad7 -r 6e01bcd111d2 mercurial/helptext/internals/dirstate-v2.txt --- a/mercurial/helptext/internals/dirstate-v2.txt Mon Oct 11 18:23:17 2021 +0200 +++ b/mercurial/helptext/internals/dirstate-v2.txt Fri Oct 08 12:57:24 2021 +0200 @@ -424,15 +424,15 @@ Only the `S_IXUSR` bit (owner has execute permission) is considered. * Offset 35: - If `HAS_MTIME` is unset, four zero bytes. - Otherwise, a 32-bit integer for expected modified time of the file - (as in `stat_result.st_mtime`), + If `HAS_MODE_AND_SIZE` is unset, four zero bytes. + Otherwise, a 32-bit integer for expected size of the file truncated to its 31 least-significant bits. Unlike in dirstate-v1, negative values are not used. * Offset 39: - If `HAS_MODE_AND_SIZE` is unset, four zero bytes. - Otherwise, a 32-bit integer for expected size of the file + If `HAS_MTIME` is unset, four zero bytes. + Otherwise, a 32-bit integer for expected modified time of the file + (as in `stat_result.st_mtime`), truncated to its 31 least-significant bits. Unlike in dirstate-v1, negative values are not used. diff -r 77fc340acad7 -r 6e01bcd111d2 rust/hg-core/src/dirstate_tree/on_disk.rs --- a/rust/hg-core/src/dirstate_tree/on_disk.rs Mon Oct 11 18:23:17 2021 +0200 +++ b/rust/hg-core/src/dirstate_tree/on_disk.rs Fri Oct 08 12:57:24 2021 +0200 @@ -114,8 +114,8 @@ #[repr(C)] struct Entry { mode: I32Be, + size: I32Be, mtime: I32Be, - size: I32Be, } /// Duration since the Unix epoch