dirstate-v2: Swap the order of size and mtime on disk
authorSimon Sapin <simon.sapin@octobus.net>
Fri, 08 Oct 2021 12:57:24 +0200
changeset 48189 6e01bcd111d2
parent 48188 77fc340acad7
child 48190 0cc0c0972164
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
mercurial/helptext/internals/dirstate-v2.txt
rust/hg-core/src/dirstate_tree/on_disk.rs
--- 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.
 
--- 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