Changeset View
Changeset View
Standalone View
Standalone View
rust/hg-core/src/dirstate_tree/dirstate_map.rs
Show First 20 Lines • Show All 418 Lines • ▼ Show 20 Line(s) | pub(super) fn empty(on_disk: &'on_disk [u8]) -> Self { | ||||
unreachable_bytes: 0, | unreachable_bytes: 0, | ||||
} | } | ||||
} | } | ||||
#[timed] | #[timed] | ||||
pub fn new_v2( | pub fn new_v2( | ||||
on_disk: &'on_disk [u8], | on_disk: &'on_disk [u8], | ||||
data_size: usize, | data_size: usize, | ||||
metadata: &[u8], | |||||
) -> Result<Self, DirstateError> { | ) -> Result<Self, DirstateError> { | ||||
if let Some(data) = on_disk.get(..data_size) { | if let Some(data) = on_disk.get(..data_size) { | ||||
Ok(on_disk::read(data)?) | Ok(on_disk::read(data, metadata)?) | ||||
} else { | } else { | ||||
Err(DirstateV2ParseError.into()) | Err(DirstateV2ParseError.into()) | ||||
} | } | ||||
} | } | ||||
#[timed] | #[timed] | ||||
pub fn new_v1( | pub fn new_v1( | ||||
on_disk: &'on_disk [u8], | on_disk: &'on_disk [u8], | ||||
▲ Show 20 Lines • Show All 651 Lines • ▼ Show 20 Line(s) | ) -> Result<Vec<u8>, DirstateError> { | ||||
node.copy_source(self.on_disk)?, | node.copy_source(self.on_disk)?, | ||||
&mut packed, | &mut packed, | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
Ok(packed) | Ok(packed) | ||||
} | } | ||||
/// Returns new data together with whether that data should be appended to | /// Returns new data and metadata together with whether that data should be | ||||
/// the existing data file whose content is at `self.on_disk` (true), | /// appended to the existing data file whose content is at | ||||
/// instead of written to a new data file (false). | /// `self.on_disk` (true), instead of written to a new data file | ||||
/// (false). | |||||
#[timed] | #[timed] | ||||
fn pack_v2( | fn pack_v2( | ||||
&mut self, | &mut self, | ||||
now: Timestamp, | now: Timestamp, | ||||
can_append: bool, | can_append: bool, | ||||
) -> Result<(Vec<u8>, bool), DirstateError> { | ) -> Result<(Vec<u8>, Vec<u8>, bool), DirstateError> { | ||||
// TODO:!how do we want to handle this in 2038? | // TODO:!how do we want to handle this in 2038? | ||||
let now: i32 = now.0.try_into().expect("time overflow"); | let now: i32 = now.0.try_into().expect("time overflow"); | ||||
let mut paths = Vec::new(); | let mut paths = Vec::new(); | ||||
for node in self.iter_nodes() { | for node in self.iter_nodes() { | ||||
let node = node?; | let node = node?; | ||||
if let Some(entry) = node.entry()? { | if let Some(entry) = node.entry()? { | ||||
if entry.mtime_is_ambiguous(now) { | if entry.mtime_is_ambiguous(now) { | ||||
paths.push( | paths.push( | ||||
▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines |