rust/hg-core/src/dirstate_tree/dirstate_map.rs
changeset 49365 79b2c98ab7b4
parent 49147 10b9f11daf15
parent 49337 6cd249556e20
child 49373 f8ec7b16c98f
equal deleted inserted replaced
49361:c2092612c424 49365:79b2c98ab7b4
    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 #[derive(Debug)]
    41 #[derive(Debug)]
    35 pub struct DirstateMap<'on_disk> {
    42 pub struct DirstateMap<'on_disk> {
    36     /// Contents of the `.hg/dirstate` file
    43     /// Contents of the `.hg/dirstate` file
    37     pub(super) on_disk: &'on_disk [u8],
    44     pub(super) on_disk: &'on_disk [u8],
    38 
    45 
    52     pub(super) unreachable_bytes: u32,
    59     pub(super) unreachable_bytes: u32,
    53 
    60 
    54     /// Size of the data used to first load this `DirstateMap`. Used in case
    61     /// Size of the data used to first load this `DirstateMap`. Used in case
    55     /// we need to write some new metadata, but no new data on disk.
    62     /// we need to write some new metadata, but no new data on disk.
    56     pub(super) old_data_size: usize,
    63     pub(super) old_data_size: usize,
       
    64 
       
    65     pub(super) dirstate_version: DirstateVersion,
    57 }
    66 }
    58 
    67 
    59 /// Using a plain `HgPathBuf` of the full path from the repository root as a
    68 /// Using a plain `HgPathBuf` of the full path from the repository root as a
    60 /// map key would also work: all paths in a given map have the same parent
    69 /// map key would also work: all paths in a given map have the same parent
    61 /// path, so comparing full paths gives the same result as comparing base
    70 /// path, so comparing full paths gives the same result as comparing base
   439             nodes_with_entry_count: 0,
   448             nodes_with_entry_count: 0,
   440             nodes_with_copy_source_count: 0,
   449             nodes_with_copy_source_count: 0,
   441             ignore_patterns_hash: [0; on_disk::IGNORE_PATTERNS_HASH_LEN],
   450             ignore_patterns_hash: [0; on_disk::IGNORE_PATTERNS_HASH_LEN],
   442             unreachable_bytes: 0,
   451             unreachable_bytes: 0,
   443             old_data_size: 0,
   452             old_data_size: 0,
       
   453             dirstate_version: DirstateVersion::V1,
   444         }
   454         }
   445     }
   455     }
   446 
   456 
   447     #[timed]
   457     #[timed]
   448     pub fn new_v2(
   458     pub fn new_v2(