diff --git a/rust/Cargo.lock b/rust/Cargo.lock
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -310,7 +310,6 @@
"im-rc 15.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"micro-timer 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/rust/hg-core/Cargo.toml b/rust/hg-core/Cargo.toml
--- a/rust/hg-core/Cargo.toml
+++ b/rust/hg-core/Cargo.toml
@@ -15,7 +15,6 @@
home = "0.5"
im-rc = "15.0.*"
lazy_static = "1.4.0"
-memchr = "2.3.3"
rand = "0.7.3"
rand_pcg = "0.2.1"
rand_distr = "0.2.2"
diff --git a/rust/hg-core/src/dirstate.rs b/rust/hg-core/src/dirstate.rs
--- a/rust/hg-core/src/dirstate.rs
+++ b/rust/hg-core/src/dirstate.rs
@@ -7,6 +7,7 @@
use crate::errors::HgError;
use crate::{utils::hg_path::HgPathBuf, FastHashMap};
+use bytes_cast::{unaligned, BytesCast};
use std::collections::hash_map;
use std::convert::TryFrom;
@@ -17,7 +18,8 @@
pub mod parsers;
pub mod status;
-#[derive(Debug, PartialEq, Clone)]
+#[derive(Debug, PartialEq, Clone, BytesCast)]
+#[repr(C)]
pub struct DirstateParents {
pub p1: [u8; 20],
pub p2: [u8; 20],
@@ -34,6 +36,16 @@
pub size: i32,
}
+#[derive(BytesCast)]
+#[repr(C)]
+struct RawEntry {
+ state: u8,
+ mode: unaligned::I32Be,
+ size: unaligned::I32Be,
+ mtime: unaligned::I32Be,
+ length: unaligned::I32Be,
+}
+
/// A `DirstateEntry` with a size of `-2` means that it was merged from the
/// other parent. This allows revert to pick the right status back during a
/// merge.
diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs b/rust/hg-core/src/dirstate/dirstate_map.rs
--- a/rust/hg-core/src/dirstate/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -386,10 +386,10 @@
}
#[timed]
- pub fn read(
+ pub fn read<'a>(
&mut self,
- file_contents: &[u8],
- ) -> Result