rust/hg-core/src/dirstate_tree/dirstate_map.rs
branchstable
changeset 49337 6cd249556e20
parent 49145 dd2503a63d33
child 49365 79b2c98ab7b4
equal deleted inserted replaced
49320:3d3d7fc6035a 49337:6cd249556e20
    29 
    29 
    30 /// Append to an existing data file if the amount of unreachable data (not used
    30 /// Append to an existing data file if the amount of unreachable data (not used
    31 /// anymore) is less than this fraction of the total amount of existing data.
    31 /// anymore) is less than this fraction of the total amount of existing data.
    32 const ACCEPTABLE_UNREACHABLE_BYTES_RATIO: f32 = 0.5;
    32 const ACCEPTABLE_UNREACHABLE_BYTES_RATIO: f32 = 0.5;
    33 
    33 
       
    34 #[derive(Debug, PartialEq, Eq)]
       
    35 /// Version of the on-disk format
       
    36 pub enum DirstateVersion {
       
    37     V1,
       
    38     V2,
       
    39 }
       
    40 
    34 pub struct DirstateMap<'on_disk> {
    41 pub struct DirstateMap<'on_disk> {
    35     /// Contents of the `.hg/dirstate` file
    42     /// Contents of the `.hg/dirstate` file
    36     pub(super) on_disk: &'on_disk [u8],
    43     pub(super) on_disk: &'on_disk [u8],
    37 
    44 
    38     pub(super) root: ChildNodes<'on_disk>,
    45     pub(super) root: ChildNodes<'on_disk>,
    51     pub(super) unreachable_bytes: u32,
    58     pub(super) unreachable_bytes: u32,
    52 
    59 
    53     /// Size of the data used to first load this `DirstateMap`. Used in case
    60     /// Size of the data used to first load this `DirstateMap`. Used in case
    54     /// we need to write some new metadata, but no new data on disk.
    61     /// we need to write some new metadata, but no new data on disk.
    55     pub(super) old_data_size: usize,
    62     pub(super) old_data_size: usize,
       
    63 
       
    64     pub(super) dirstate_version: DirstateVersion,
    56 }
    65 }
    57 
    66 
    58 /// Using a plain `HgPathBuf` of the full path from the repository root as a
    67 /// Using a plain `HgPathBuf` of the full path from the repository root as a
    59 /// map key would also work: all paths in a given map have the same parent
    68 /// map key would also work: all paths in a given map have the same parent
    60 /// path, so comparing full paths gives the same result as comparing base
    69 /// path, so comparing full paths gives the same result as comparing base
   432             nodes_with_entry_count: 0,
   441             nodes_with_entry_count: 0,
   433             nodes_with_copy_source_count: 0,
   442             nodes_with_copy_source_count: 0,
   434             ignore_patterns_hash: [0; on_disk::IGNORE_PATTERNS_HASH_LEN],
   443             ignore_patterns_hash: [0; on_disk::IGNORE_PATTERNS_HASH_LEN],
   435             unreachable_bytes: 0,
   444             unreachable_bytes: 0,
   436             old_data_size: 0,
   445             old_data_size: 0,
       
   446             dirstate_version: DirstateVersion::V1,
   437         }
   447         }
   438     }
   448     }
   439 
   449 
   440     #[timed]
   450     #[timed]
   441     pub fn new_v2(
   451     pub fn new_v2(