30 |
30 |
31 /// Append to an existing data file if the amount of unreachable data (not used |
31 /// Append to an existing data file if the amount of unreachable data (not used |
32 /// anymore) is less than this fraction of the total amount of existing data. |
32 /// anymore) is less than this fraction of the total amount of existing data. |
33 const ACCEPTABLE_UNREACHABLE_BYTES_RATIO: f32 = 0.5; |
33 const ACCEPTABLE_UNREACHABLE_BYTES_RATIO: f32 = 0.5; |
34 |
34 |
|
35 #[derive(Debug)] |
35 pub struct DirstateMap<'on_disk> { |
36 pub struct DirstateMap<'on_disk> { |
36 /// Contents of the `.hg/dirstate` file |
37 /// Contents of the `.hg/dirstate` file |
37 pub(super) on_disk: &'on_disk [u8], |
38 pub(super) on_disk: &'on_disk [u8], |
38 |
39 |
39 pub(super) root: ChildNodes<'on_disk>, |
40 pub(super) root: ChildNodes<'on_disk>, |
59 /// string prefix. |
60 /// string prefix. |
60 pub(super) type NodeKey<'on_disk> = WithBasename<Cow<'on_disk, HgPath>>; |
61 pub(super) type NodeKey<'on_disk> = WithBasename<Cow<'on_disk, HgPath>>; |
61 |
62 |
62 /// Similar to `&'tree Cow<'on_disk, HgPath>`, but can also be returned |
63 /// Similar to `&'tree Cow<'on_disk, HgPath>`, but can also be returned |
63 /// for on-disk nodes that don’t actually have a `Cow` to borrow. |
64 /// for on-disk nodes that don’t actually have a `Cow` to borrow. |
|
65 #[derive(Debug)] |
64 pub(super) enum BorrowedPath<'tree, 'on_disk> { |
66 pub(super) enum BorrowedPath<'tree, 'on_disk> { |
65 InMemory(&'tree HgPathBuf), |
67 InMemory(&'tree HgPathBuf), |
66 OnDisk(&'on_disk HgPath), |
68 OnDisk(&'on_disk HgPath), |
67 } |
69 } |
68 |
70 |
|
71 #[derive(Debug)] |
69 pub(super) enum ChildNodes<'on_disk> { |
72 pub(super) enum ChildNodes<'on_disk> { |
70 InMemory(FastHashMap<NodeKey<'on_disk>, Node<'on_disk>>), |
73 InMemory(FastHashMap<NodeKey<'on_disk>, Node<'on_disk>>), |
71 OnDisk(&'on_disk [on_disk::Node]), |
74 OnDisk(&'on_disk [on_disk::Node]), |
72 } |
75 } |
73 |
76 |
|
77 #[derive(Debug)] |
74 pub(super) enum ChildNodesRef<'tree, 'on_disk> { |
78 pub(super) enum ChildNodesRef<'tree, 'on_disk> { |
75 InMemory(&'tree FastHashMap<NodeKey<'on_disk>, Node<'on_disk>>), |
79 InMemory(&'tree FastHashMap<NodeKey<'on_disk>, Node<'on_disk>>), |
76 OnDisk(&'on_disk [on_disk::Node]), |
80 OnDisk(&'on_disk [on_disk::Node]), |
77 } |
81 } |
78 |
82 |
|
83 #[derive(Debug)] |
79 pub(super) enum NodeRef<'tree, 'on_disk> { |
84 pub(super) enum NodeRef<'tree, 'on_disk> { |
80 InMemory(&'tree NodeKey<'on_disk>, &'tree Node<'on_disk>), |
85 InMemory(&'tree NodeKey<'on_disk>, &'tree Node<'on_disk>), |
81 OnDisk(&'on_disk on_disk::Node), |
86 OnDisk(&'on_disk on_disk::Node), |
82 } |
87 } |
83 |
88 |
381 } |
386 } |
382 } |
387 } |
383 } |
388 } |
384 |
389 |
385 /// Represents a file or a directory |
390 /// Represents a file or a directory |
386 #[derive(Default)] |
391 #[derive(Default, Debug)] |
387 pub(super) struct Node<'on_disk> { |
392 pub(super) struct Node<'on_disk> { |
388 pub(super) data: NodeData, |
393 pub(super) data: NodeData, |
389 |
394 |
390 pub(super) copy_source: Option<Cow<'on_disk, HgPath>>, |
395 pub(super) copy_source: Option<Cow<'on_disk, HgPath>>, |
391 |
396 |
397 /// How many (non-inclusive) descendants of this node have an entry whose |
402 /// How many (non-inclusive) descendants of this node have an entry whose |
398 /// state is "tracked". |
403 /// state is "tracked". |
399 pub(super) tracked_descendants_count: u32, |
404 pub(super) tracked_descendants_count: u32, |
400 } |
405 } |
401 |
406 |
|
407 #[derive(Debug)] |
402 pub(super) enum NodeData { |
408 pub(super) enum NodeData { |
403 Entry(DirstateEntry), |
409 Entry(DirstateEntry), |
404 CachedDirectory { mtime: TruncatedTimestamp }, |
410 CachedDirectory { mtime: TruncatedTimestamp }, |
405 None, |
411 None, |
406 } |
412 } |