rust/hg-core/src/dirstate_tree/dirstate_map.rs
branchstable
changeset 50221 1891086f6c7f
parent 49373 f8ec7b16c98f
child 50222 ecd28d89c29e
equal deleted inserted replaced
50220:35ea3c139104 50221:1891086f6c7f
    34 #[derive(Debug, PartialEq, Eq)]
    34 #[derive(Debug, PartialEq, Eq)]
    35 /// Version of the on-disk format
    35 /// Version of the on-disk format
    36 pub enum DirstateVersion {
    36 pub enum DirstateVersion {
    37     V1,
    37     V1,
    38     V2,
    38     V2,
       
    39 }
       
    40 
       
    41 #[derive(Debug, PartialEq, Eq)]
       
    42 pub enum DirstateMapWriteMode {
       
    43     Auto,
       
    44     ForceNewDataFile,
    39 }
    45 }
    40 
    46 
    41 #[derive(Debug)]
    47 #[derive(Debug)]
    42 pub struct DirstateMap<'on_disk> {
    48 pub struct DirstateMap<'on_disk> {
    43     /// Contents of the `.hg/dirstate` file
    49     /// Contents of the `.hg/dirstate` file
  1249     /// `map.on_disk` (true), instead of written to a new data file
  1255     /// `map.on_disk` (true), instead of written to a new data file
  1250     /// (false), and the previous size of data on disk.
  1256     /// (false), and the previous size of data on disk.
  1251     #[timed]
  1257     #[timed]
  1252     pub fn pack_v2(
  1258     pub fn pack_v2(
  1253         &self,
  1259         &self,
  1254         can_append: bool,
  1260         write_mode: DirstateMapWriteMode,
  1255     ) -> Result<(Vec<u8>, on_disk::TreeMetadata, bool, usize), DirstateError>
  1261     ) -> Result<(Vec<u8>, on_disk::TreeMetadata, bool, usize), DirstateError>
  1256     {
  1262     {
  1257         let map = self.get_map();
  1263         let map = self.get_map();
  1258         on_disk::write(map, can_append)
  1264         on_disk::write(map, write_mode)
  1259     }
  1265     }
  1260 
  1266 
  1261     /// `callback` allows the caller to process and do something with the
  1267     /// `callback` allows the caller to process and do something with the
  1262     /// results of the status. This is needed to do so efficiently (i.e.
  1268     /// results of the status. This is needed to do so efficiently (i.e.
  1263     /// without cloning the `DirstateStatus` object with its paths) because
  1269     /// without cloning the `DirstateStatus` object with its paths) because
  1810             false,
  1816             false,
  1811             None,
  1817             None,
  1812         )?;
  1818         )?;
  1813 
  1819 
  1814         let (packed, metadata, _should_append, _old_data_size) =
  1820         let (packed, metadata, _should_append, _old_data_size) =
  1815             map.pack_v2(false)?;
  1821             map.pack_v2(DirstateMapWriteMode::ForceNewDataFile)?;
  1816         let packed_len = packed.len();
  1822         let packed_len = packed.len();
  1817         assert!(packed_len > 0);
  1823         assert!(packed_len > 0);
  1818 
  1824 
  1819         // Recreate "from disk"
  1825         // Recreate "from disk"
  1820         let mut map = OwningDirstateMap::new_v2(
  1826         let mut map = OwningDirstateMap::new_v2(