rust/hg-core/src/dirstate_tree/dirstate_map.rs
changeset 47682 78f7f0d490ee
parent 47681 d94118365ec5
child 47683 284a20269a97
equal deleted inserted replaced
47681:d94118365ec5 47682:78f7f0d490ee
   422 
   422 
   423     #[timed]
   423     #[timed]
   424     pub fn new_v2(
   424     pub fn new_v2(
   425         on_disk: &'on_disk [u8],
   425         on_disk: &'on_disk [u8],
   426         data_size: usize,
   426         data_size: usize,
       
   427         metadata: &[u8],
   427     ) -> Result<Self, DirstateError> {
   428     ) -> Result<Self, DirstateError> {
   428         if let Some(data) = on_disk.get(..data_size) {
   429         if let Some(data) = on_disk.get(..data_size) {
   429             Ok(on_disk::read(data)?)
   430             Ok(on_disk::read(data, metadata)?)
   430         } else {
   431         } else {
   431             Err(DirstateV2ParseError.into())
   432             Err(DirstateV2ParseError.into())
   432         }
   433         }
   433     }
   434     }
   434 
   435 
  1092             }
  1093             }
  1093         }
  1094         }
  1094         Ok(packed)
  1095         Ok(packed)
  1095     }
  1096     }
  1096 
  1097 
  1097     /// Returns new data together with whether that data should be appended to
  1098     /// Returns new data and metadata together with whether that data should be
  1098     /// the existing data file whose content is at `self.on_disk` (true),
  1099     /// appended to the existing data file whose content is at
  1099     /// instead of written to a new data file (false).
  1100     /// `self.on_disk` (true), instead of written to a new data file
       
  1101     /// (false).
  1100     #[timed]
  1102     #[timed]
  1101     fn pack_v2(
  1103     fn pack_v2(
  1102         &mut self,
  1104         &mut self,
  1103         now: Timestamp,
  1105         now: Timestamp,
  1104         can_append: bool,
  1106         can_append: bool,
  1105     ) -> Result<(Vec<u8>, bool), DirstateError> {
  1107     ) -> Result<(Vec<u8>, Vec<u8>, bool), DirstateError> {
  1106         // TODO: how do we want to handle this in 2038?
  1108         // TODO: how do we want to handle this in 2038?
  1107         let now: i32 = now.0.try_into().expect("time overflow");
  1109         let now: i32 = now.0.try_into().expect("time overflow");
  1108         let mut paths = Vec::new();
  1110         let mut paths = Vec::new();
  1109         for node in self.iter_nodes() {
  1111         for node in self.iter_nodes() {
  1110             let node = node?;
  1112             let node = node?;