--- a/rust/hg-core/src/dirstate/parsers.rs Mon Sep 20 14:21:18 2021 -0400
+++ b/rust/hg-core/src/dirstate/parsers.rs Fri Sep 17 12:42:24 2021 +0200
@@ -6,11 +6,11 @@
use crate::errors::HgError;
use crate::utils::hg_path::HgPath;
use crate::{
- dirstate::{CopyMap, EntryState, RawEntry, StateMap},
+ dirstate::{CopyMap, EntryState, StateMap},
DirstateEntry, DirstateParents,
};
use byteorder::{BigEndian, WriteBytesExt};
-use bytes_cast::BytesCast;
+use bytes_cast::{unaligned, BytesCast};
use micro_timer::timed;
use std::convert::{TryFrom, TryInto};
@@ -48,6 +48,16 @@
Ok((parents, entries, copies))
}
+#[derive(BytesCast)]
+#[repr(C)]
+pub(super) struct RawEntry {
+ state: u8,
+ mode: unaligned::I32Be,
+ size: unaligned::I32Be,
+ mtime: unaligned::I32Be,
+ length: unaligned::I32Be,
+}
+
pub fn parse_dirstate_entries<'a>(
mut contents: &'a [u8],
mut each_entry: impl FnMut(
@@ -131,33 +141,6 @@
/// Seconds since the Unix epoch
pub struct Timestamp(pub i64);
-impl DirstateEntry {
- pub fn mtime_is_ambiguous(&self, now: i32) -> bool {
- self.state == EntryState::Normal && self.mtime == now
- }
-
- pub fn clear_ambiguous_mtime(&mut self, now: i32) -> bool {
- let ambiguous = self.mtime_is_ambiguous(now);
- if ambiguous {
- // The file was last modified "simultaneously" with the current
- // write to dirstate (i.e. within the same second for file-
- // systems with a granularity of 1 sec). This commonly happens
- // for at least a couple of files on 'update'.
- // The user could change the file without changing its size
- // within the same second. Invalidate the file's mtime in
- // dirstate, forcing future 'status' calls to compare the
- // contents of the file if the size is the same. This prevents
- // mistakenly treating such files as clean.
- self.clear_mtime()
- }
- ambiguous
- }
-
- pub fn clear_mtime(&mut self) {
- self.mtime = -1;
- }
-}
-
pub fn pack_dirstate(
state_map: &mut StateMap,
copy_map: &CopyMap,