--- a/rust/hg-core/src/dirstate/parsers.rs Sun Sep 13 22:14:25 2020 -0400
+++ b/rust/hg-core/src/dirstate/parsers.rs Thu Apr 08 21:46:54 2021 +0200
@@ -73,7 +73,6 @@
}
/// `now` is the duration in seconds since the Unix epoch
-#[cfg(not(feature = "dirstate-tree"))]
pub fn pack_dirstate(
state_map: &mut StateMap,
copy_map: &CopyMap,
@@ -146,79 +145,6 @@
Ok(packed)
}
-/// `now` is the duration in seconds since the Unix epoch
-#[cfg(feature = "dirstate-tree")]
-pub fn pack_dirstate(
- state_map: &mut StateMap,
- copy_map: &CopyMap,
- parents: DirstateParents,
- now: Duration,
-) -> Result<Vec<u8>, DirstatePackError> {
- // TODO move away from i32 before 2038.
- let now: i32 = now.as_secs().try_into().expect("time overflow");
-
- let expected_size: usize = state_map
- .iter()
- .map(|(filename, _)| {
- let mut length = MIN_ENTRY_SIZE + filename.len();
- if let Some(copy) = copy_map.get(&filename) {
- length += copy.len() + 1;
- }
- length
- })
- .sum();
- let expected_size = expected_size + PARENT_SIZE * 2;
-
- let mut packed = Vec::with_capacity(expected_size);
- let mut new_state_map = vec![];
-
- packed.extend(&parents.p1);
- packed.extend(&parents.p2);
-
- for (filename, entry) in state_map.iter() {
- let new_filename = filename.to_owned();
- let mut new_mtime: i32 = entry.mtime;
- if entry.state == EntryState::Normal && entry.mtime == now {
- // 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.
- new_mtime = -1;
- new_state_map.push((
- filename.to_owned(),
- DirstateEntry {
- mtime: new_mtime,
- ..entry
- },
- ));
- }
- let mut new_filename = new_filename.into_vec();
- if let Some(copy) = copy_map.get(&filename) {
- new_filename.push(b'\0');
- new_filename.extend(copy.bytes());
- }
-
- packed.write_u8(entry.state.into())?;
- packed.write_i32::<BigEndian>(entry.mode)?;
- packed.write_i32::<BigEndian>(entry.size)?;
- packed.write_i32::<BigEndian>(new_mtime)?;
- packed.write_i32::<BigEndian>(new_filename.len() as i32)?;
- packed.extend(new_filename)
- }
-
- if packed.len() != expected_size {
- return Err(DirstatePackError::BadSize(expected_size, packed.len()));
- }
-
- state_map.extend(new_state_map);
-
- Ok(packed)
-}
#[cfg(test)]
mod tests {