Show More
@@ -31,6 +31,13 b' use crate::StatusOptions;' | |||||
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], | |
@@ -53,6 +60,8 b" pub struct DirstateMap<'on_disk> {" | |||||
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 | |
@@ -434,6 +443,7 b" impl<'on_disk> DirstateMap<'on_disk> {" | |||||
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 |
@@ -3,6 +3,7 b'' | |||||
3 | //! See `mercurial/helptext/internals/dirstate-v2.txt` |
|
3 | //! See `mercurial/helptext/internals/dirstate-v2.txt` | |
4 |
|
4 | |||
5 | use crate::dirstate::TruncatedTimestamp; |
|
5 | use crate::dirstate::TruncatedTimestamp; | |
|
6 | use crate::dirstate_tree::dirstate_map::DirstateVersion; | |||
6 | use crate::dirstate_tree::dirstate_map::{self, DirstateMap, NodeRef}; |
|
7 | use crate::dirstate_tree::dirstate_map::{self, DirstateMap, NodeRef}; | |
7 | use crate::dirstate_tree::path_with_basename::WithBasename; |
|
8 | use crate::dirstate_tree::path_with_basename::WithBasename; | |
8 | use crate::errors::HgError; |
|
9 | use crate::errors::HgError; | |
@@ -276,7 +277,9 b" pub(super) fn read<'on_disk>(" | |||||
276 | metadata: &[u8], |
|
277 | metadata: &[u8], | |
277 | ) -> Result<DirstateMap<'on_disk>, DirstateV2ParseError> { |
|
278 | ) -> Result<DirstateMap<'on_disk>, DirstateV2ParseError> { | |
278 | if on_disk.is_empty() { |
|
279 | if on_disk.is_empty() { | |
279 |
|
|
280 | let mut map = DirstateMap::empty(on_disk); | |
|
281 | map.dirstate_version = DirstateVersion::V2; | |||
|
282 | return Ok(map); | |||
280 | } |
|
283 | } | |
281 | let (meta, _) = TreeMetadata::from_bytes(metadata) |
|
284 | let (meta, _) = TreeMetadata::from_bytes(metadata) | |
282 | .map_err(|_| DirstateV2ParseError)?; |
|
285 | .map_err(|_| DirstateV2ParseError)?; | |
@@ -291,6 +294,7 b" pub(super) fn read<'on_disk>(" | |||||
291 | ignore_patterns_hash: meta.ignore_patterns_hash, |
|
294 | ignore_patterns_hash: meta.ignore_patterns_hash, | |
292 | unreachable_bytes: meta.unreachable_bytes.get(), |
|
295 | unreachable_bytes: meta.unreachable_bytes.get(), | |
293 | old_data_size: on_disk.len(), |
|
296 | old_data_size: on_disk.len(), | |
|
297 | dirstate_version: DirstateVersion::V2, | |||
294 | }; |
|
298 | }; | |
295 | Ok(dirstate_map) |
|
299 | Ok(dirstate_map) | |
296 | } |
|
300 | } |
@@ -4,6 +4,7 b' use crate::dirstate::status::StatusPath;' | |||||
4 | use crate::dirstate_tree::dirstate_map::BorrowedPath; |
|
4 | use crate::dirstate_tree::dirstate_map::BorrowedPath; | |
5 | use crate::dirstate_tree::dirstate_map::ChildNodesRef; |
|
5 | use crate::dirstate_tree::dirstate_map::ChildNodesRef; | |
6 | use crate::dirstate_tree::dirstate_map::DirstateMap; |
|
6 | use crate::dirstate_tree::dirstate_map::DirstateMap; | |
|
7 | use crate::dirstate_tree::dirstate_map::DirstateVersion; | |||
7 | use crate::dirstate_tree::dirstate_map::NodeData; |
|
8 | use crate::dirstate_tree::dirstate_map::NodeData; | |
8 | use crate::dirstate_tree::dirstate_map::NodeRef; |
|
9 | use crate::dirstate_tree::dirstate_map::NodeRef; | |
9 | use crate::dirstate_tree::on_disk::DirstateV2ParseError; |
|
10 | use crate::dirstate_tree::on_disk::DirstateV2ParseError; | |
@@ -61,6 +62,16 b" pub fn status<'dirstate>(" | |||||
61 |
|
62 | |||
62 | let (ignore_fn, warnings, patterns_changed): (IgnoreFnType, _, _) = |
|
63 | let (ignore_fn, warnings, patterns_changed): (IgnoreFnType, _, _) = | |
63 | if options.list_ignored || options.list_unknown { |
|
64 | if options.list_ignored || options.list_unknown { | |
|
65 | let (ignore_fn, warnings, changed) = match dmap.dirstate_version { | |||
|
66 | DirstateVersion::V1 => { | |||
|
67 | let (ignore_fn, warnings) = get_ignore_function( | |||
|
68 | ignore_files, | |||
|
69 | &root_dir, | |||
|
70 | &mut |_pattern_bytes| {}, | |||
|
71 | )?; | |||
|
72 | (ignore_fn, warnings, None) | |||
|
73 | } | |||
|
74 | DirstateVersion::V2 => { | |||
64 | let mut hasher = Sha1::new(); |
|
75 | let mut hasher = Sha1::new(); | |
65 | let (ignore_fn, warnings) = get_ignore_function( |
|
76 | let (ignore_fn, warnings) = get_ignore_function( | |
66 | ignore_files, |
|
77 | ignore_files, | |
@@ -71,6 +82,9 b" pub fn status<'dirstate>(" | |||||
71 | let changed = new_hash != dmap.ignore_patterns_hash; |
|
82 | let changed = new_hash != dmap.ignore_patterns_hash; | |
72 | dmap.ignore_patterns_hash = new_hash; |
|
83 | dmap.ignore_patterns_hash = new_hash; | |
73 | (ignore_fn, warnings, Some(changed)) |
|
84 | (ignore_fn, warnings, Some(changed)) | |
|
85 | } | |||
|
86 | }; | |||
|
87 | (ignore_fn, warnings, changed) | |||
74 | } else { |
|
88 | } else { | |
75 | (Box::new(|&_| true), vec![], None) |
|
89 | (Box::new(|&_| true), vec![], None) | |
76 | }; |
|
90 | }; | |
@@ -135,7 +149,8 b" pub fn status<'dirstate>(" | |||||
135 |
|
149 | |||
136 | outcome.dirty = common.ignore_patterns_have_changed == Some(true) |
|
150 | outcome.dirty = common.ignore_patterns_have_changed == Some(true) | |
137 | || !outdated.is_empty() |
|
151 | || !outdated.is_empty() | |
138 |
|| !new_cachable.is_empty() |
|
152 | || (!new_cachable.is_empty() | |
|
153 | && dmap.dirstate_version == DirstateVersion::V2); | |||
139 |
|
154 | |||
140 | // Remove outdated mtimes before adding new mtimes, in case a given |
|
155 | // Remove outdated mtimes before adding new mtimes, in case a given | |
141 | // directory is both |
|
156 | // directory is both |
General Comments 0
You need to be logged in to leave comments.
Login now