Show More
@@ -3,12 +3,6 b'' | |||
|
3 | 3 | version = 3 |
|
4 | 4 | |
|
5 | 5 | [[package]] |
|
6 | name = "Inflector" | |
|
7 | version = "0.11.4" | |
|
8 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
9 | checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" | |
|
10 | ||
|
11 | [[package]] | |
|
12 | 6 | name = "adler" |
|
13 | 7 | version = "1.0.2" |
|
14 | 8 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -35,12 +29,6 b' dependencies = [' | |||
|
35 | 29 | ] |
|
36 | 30 | |
|
37 | 31 | [[package]] |
|
38 | name = "aliasable" | |
|
39 | version = "0.1.3" | |
|
40 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
41 | checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" | |
|
42 | ||
|
43 | [[package]] | |
|
44 | 32 | name = "android_system_properties" |
|
45 | 33 | version = "0.1.5" |
|
46 | 34 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -539,7 +527,6 b' dependencies = [' | |||
|
539 | 527 | "logging_timer", |
|
540 | 528 | "memmap2", |
|
541 | 529 | "once_cell", |
|
542 | "ouroboros", | |
|
543 | 530 | "pretty_assertions", |
|
544 | 531 | "rand 0.8.5", |
|
545 | 532 | "rand_distr", |
@@ -547,6 +534,7 b' dependencies = [' | |||
|
547 | 534 | "rayon", |
|
548 | 535 | "regex", |
|
549 | 536 | "same-file", |
|
537 | "self_cell", | |
|
550 | 538 | "sha-1 0.10.0", |
|
551 | 539 | "tempfile", |
|
552 | 540 | "thread_local", |
@@ -809,29 +797,6 b' source = "registry+https://github.com/ru' | |||
|
809 | 797 | checksum = "7b5bf27447411e9ee3ff51186bf7a08e16c341efdde93f4d823e8844429bed7e" |
|
810 | 798 | |
|
811 | 799 | [[package]] |
|
812 | name = "ouroboros" | |
|
813 | version = "0.15.5" | |
|
814 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
815 | checksum = "dfbb50b356159620db6ac971c6d5c9ab788c9cc38a6f49619fca2a27acb062ca" | |
|
816 | dependencies = [ | |
|
817 | "aliasable", | |
|
818 | "ouroboros_macro", | |
|
819 | ] | |
|
820 | ||
|
821 | [[package]] | |
|
822 | name = "ouroboros_macro" | |
|
823 | version = "0.15.5" | |
|
824 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
825 | checksum = "4a0d9d1a6191c4f391f87219d1ea42b23f09ee84d64763cd05ee6ea88d9f384d" | |
|
826 | dependencies = [ | |
|
827 | "Inflector", | |
|
828 | "proc-macro-error", | |
|
829 | "proc-macro2", | |
|
830 | "quote", | |
|
831 | "syn", | |
|
832 | ] | |
|
833 | ||
|
834 | [[package]] | |
|
835 | 800 | name = "output_vt100" |
|
836 | 801 | version = "0.1.3" |
|
837 | 802 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1130,6 +1095,12 b' source = "registry+https://github.com/ru' | |||
|
1130 | 1095 | checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" |
|
1131 | 1096 | |
|
1132 | 1097 | [[package]] |
|
1098 | name = "self_cell" | |
|
1099 | version = "1.0.0" | |
|
1100 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
1101 | checksum = "4a3926e239738d36060909ffe6f511502f92149a45a1fade7fe031cb2d33e88b" | |
|
1102 | ||
|
1103 | [[package]] | |
|
1133 | 1104 | name = "semver" |
|
1134 | 1105 | version = "1.0.14" |
|
1135 | 1106 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -20,12 +20,12 b' itertools = "0.10.5"' | |||
|
20 | 20 | lazy_static = "1.4.0" |
|
21 | 21 | libc = "0.2.137" |
|
22 | 22 | logging_timer = "1.1.0" |
|
23 | ouroboros = "0.15.5" | |
|
24 | 23 | rand = "0.8.5" |
|
25 | 24 | rand_pcg = "0.3.1" |
|
26 | 25 | rand_distr = "0.4.3" |
|
27 | 26 | rayon = "1.7.0" |
|
28 | 27 | regex = "1.7.0" |
|
28 | self_cell = "1.0" | |
|
29 | 29 | sha-1 = "0.10.0" |
|
30 | 30 | twox-hash = "1.6.3" |
|
31 | 31 | same-file = "1.0.6" |
@@ -1,19 +1,18 b'' | |||
|
1 | 1 | use crate::{DirstateError, DirstateParents}; |
|
2 | 2 | |
|
3 | 3 | use super::dirstate_map::DirstateMap; |
|
4 | use self_cell::self_cell; | |
|
4 | 5 | use std::ops::Deref; |
|
5 | 6 | |
|
6 | use ouroboros::self_referencing; | |
|
7 | ||
|
8 | /// Keep a `DirstateMap<'on_disk>` next to the `on_disk` buffer that it | |
|
9 | /// borrows. | |
|
10 | #[self_referencing] | |
|
11 | pub struct OwningDirstateMap { | |
|
12 | on_disk: Box<dyn Deref<Target = [u8]> + Send>, | |
|
13 | #[borrows(on_disk)] | |
|
14 | #[covariant] | |
|
15 | map: DirstateMap<'this>, | |
|
16 | } | |
|
7 | self_cell!( | |
|
8 | /// Keep a `DirstateMap<'owner>` next to the `owner` buffer that it | |
|
9 | /// borrows. | |
|
10 | pub struct OwningDirstateMap { | |
|
11 | owner: Box<dyn Deref<Target = [u8]> + Send>, | |
|
12 | #[covariant] | |
|
13 | dependent: DirstateMap, | |
|
14 | } | |
|
15 | ); | |
|
17 | 16 | |
|
18 | 17 | impl OwningDirstateMap { |
|
19 | 18 | pub fn new_empty<OnDisk>(on_disk: OnDisk) -> Self |
@@ -22,11 +21,7 b' impl OwningDirstateMap {' | |||
|
22 | 21 | { |
|
23 | 22 | let on_disk = Box::new(on_disk); |
|
24 | 23 | |
|
25 | OwningDirstateMapBuilder { | |
|
26 | on_disk, | |
|
27 | map_builder: |bytes| DirstateMap::empty(bytes), | |
|
28 | } | |
|
29 | .build() | |
|
24 | OwningDirstateMap::new(on_disk, |bytes| DirstateMap::empty(bytes)) | |
|
30 | 25 | } |
|
31 | 26 | |
|
32 | 27 | pub fn new_v1<OnDisk>( |
@@ -40,16 +35,12 b' impl OwningDirstateMap {' | |||
|
40 | 35 | let mut parents = DirstateParents::NULL; |
|
41 | 36 | |
|
42 | 37 | Ok(( |
|
43 |
OwningDirstateMap |
|
|
44 | on_disk, | |
|
45 | map_builder: |bytes| { | |
|
46 | DirstateMap::new_v1(bytes, identity).map(|(dmap, p)| { | |
|
47 | parents = p.unwrap_or(DirstateParents::NULL); | |
|
48 | dmap | |
|
49 | }) | |
|
50 | }, | |
|
51 | } | |
|
52 | .try_build()?, | |
|
38 | OwningDirstateMap::try_new(on_disk, |bytes| { | |
|
39 | DirstateMap::new_v1(bytes, identity).map(|(dmap, p)| { | |
|
40 | parents = p.unwrap_or(DirstateParents::NULL); | |
|
41 | dmap | |
|
42 | }) | |
|
43 | })?, | |
|
53 | 44 | parents, |
|
54 | 45 | )) |
|
55 | 46 | } |
@@ -66,28 +57,24 b' impl OwningDirstateMap {' | |||
|
66 | 57 | { |
|
67 | 58 | let on_disk = Box::new(on_disk); |
|
68 | 59 | |
|
69 |
OwningDirstateMap |
|
|
70 | on_disk, | |
|
71 | map_builder: |bytes| { | |
|
72 | DirstateMap::new_v2(bytes, data_size, metadata, uuid, identity) | |
|
73 | }, | |
|
74 | } | |
|
75 | .try_build() | |
|
60 | OwningDirstateMap::try_new(on_disk, |bytes| { | |
|
61 | DirstateMap::new_v2(bytes, data_size, metadata, uuid, identity) | |
|
62 | }) | |
|
76 | 63 | } |
|
77 | 64 | |
|
78 | 65 | pub fn with_dmap_mut<R>( |
|
79 | 66 | &mut self, |
|
80 | 67 | f: impl FnOnce(&mut DirstateMap) -> R, |
|
81 | 68 | ) -> R { |
|
82 |
self.with_ |
|
|
69 | self.with_dependent_mut(|_owner, dmap| f(dmap)) | |
|
83 | 70 | } |
|
84 | 71 | |
|
85 | 72 | pub fn get_map(&self) -> &DirstateMap { |
|
86 |
self.borrow_ |
|
|
73 | self.borrow_dependent() | |
|
87 | 74 | } |
|
88 | 75 | |
|
89 | 76 | pub fn on_disk(&self) -> &[u8] { |
|
90 |
self.borrow_o |
|
|
77 | self.borrow_owner() | |
|
91 | 78 | } |
|
92 | 79 | |
|
93 | 80 | pub fn old_uuid(&self) -> Option<&[u8]> { |
General Comments 0
You need to be logged in to leave comments.
Login now