##// END OF EJS Templates
rust-hg-core: move from `ouroboros` to `self_cell`...
Raphaël Gomès -
r51575:2cc5de26 default
parent child Browse files
Show More
@@ -3,12 +3,6
3 version = 3
3 version = 3
4
4
5 [[package]]
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 name = "adler"
6 name = "adler"
13 version = "1.0.2"
7 version = "1.0.2"
14 source = "registry+https://github.com/rust-lang/crates.io-index"
8 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -35,12 +29,6 dependencies = [
35 ]
29 ]
36
30
37 [[package]]
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 name = "android_system_properties"
32 name = "android_system_properties"
45 version = "0.1.5"
33 version = "0.1.5"
46 source = "registry+https://github.com/rust-lang/crates.io-index"
34 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -539,7 +527,6 dependencies = [
539 "logging_timer",
527 "logging_timer",
540 "memmap2",
528 "memmap2",
541 "once_cell",
529 "once_cell",
542 "ouroboros",
543 "pretty_assertions",
530 "pretty_assertions",
544 "rand 0.8.5",
531 "rand 0.8.5",
545 "rand_distr",
532 "rand_distr",
@@ -547,6 +534,7 dependencies = [
547 "rayon",
534 "rayon",
548 "regex",
535 "regex",
549 "same-file",
536 "same-file",
537 "self_cell",
550 "sha-1 0.10.0",
538 "sha-1 0.10.0",
551 "tempfile",
539 "tempfile",
552 "thread_local",
540 "thread_local",
@@ -809,29 +797,6 source = "registry+https://github.com/ru
809 checksum = "7b5bf27447411e9ee3ff51186bf7a08e16c341efdde93f4d823e8844429bed7e"
797 checksum = "7b5bf27447411e9ee3ff51186bf7a08e16c341efdde93f4d823e8844429bed7e"
810
798
811 [[package]]
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 name = "output_vt100"
800 name = "output_vt100"
836 version = "0.1.3"
801 version = "0.1.3"
837 source = "registry+https://github.com/rust-lang/crates.io-index"
802 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1130,6 +1095,12 source = "registry+https://github.com/ru
1130 checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898"
1095 checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898"
1131
1096
1132 [[package]]
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 name = "semver"
1104 name = "semver"
1134 version = "1.0.14"
1105 version = "1.0.14"
1135 source = "registry+https://github.com/rust-lang/crates.io-index"
1106 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -20,12 +20,12 itertools = "0.10.5"
20 lazy_static = "1.4.0"
20 lazy_static = "1.4.0"
21 libc = "0.2.137"
21 libc = "0.2.137"
22 logging_timer = "1.1.0"
22 logging_timer = "1.1.0"
23 ouroboros = "0.15.5"
24 rand = "0.8.5"
23 rand = "0.8.5"
25 rand_pcg = "0.3.1"
24 rand_pcg = "0.3.1"
26 rand_distr = "0.4.3"
25 rand_distr = "0.4.3"
27 rayon = "1.7.0"
26 rayon = "1.7.0"
28 regex = "1.7.0"
27 regex = "1.7.0"
28 self_cell = "1.0"
29 sha-1 = "0.10.0"
29 sha-1 = "0.10.0"
30 twox-hash = "1.6.3"
30 twox-hash = "1.6.3"
31 same-file = "1.0.6"
31 same-file = "1.0.6"
@@ -1,19 +1,18
1 use crate::{DirstateError, DirstateParents};
1 use crate::{DirstateError, DirstateParents};
2
2
3 use super::dirstate_map::DirstateMap;
3 use super::dirstate_map::DirstateMap;
4 use self_cell::self_cell;
4 use std::ops::Deref;
5 use std::ops::Deref;
5
6
6 use ouroboros::self_referencing;
7 self_cell!(
7
8 /// Keep a `DirstateMap<'owner>` next to the `owner` buffer that it
8 /// Keep a `DirstateMap<'on_disk>` next to the `on_disk` buffer that it
9 /// borrows.
9 /// borrows.
10 #[self_referencing]
11 pub struct OwningDirstateMap {
10 pub struct OwningDirstateMap {
12 on_disk: Box<dyn Deref<Target = [u8]> + Send>,
11 owner: Box<dyn Deref<Target = [u8]> + Send>,
13 #[borrows(on_disk)]
14 #[covariant]
12 #[covariant]
15 map: DirstateMap<'this>,
13 dependent: DirstateMap,
16 }
14 }
15 );
17
16
18 impl OwningDirstateMap {
17 impl OwningDirstateMap {
19 pub fn new_empty<OnDisk>(on_disk: OnDisk) -> Self
18 pub fn new_empty<OnDisk>(on_disk: OnDisk) -> Self
@@ -22,11 +21,7 impl OwningDirstateMap {
22 {
21 {
23 let on_disk = Box::new(on_disk);
22 let on_disk = Box::new(on_disk);
24
23
25 OwningDirstateMapBuilder {
24 OwningDirstateMap::new(on_disk, |bytes| DirstateMap::empty(bytes))
26 on_disk,
27 map_builder: |bytes| DirstateMap::empty(bytes),
28 }
29 .build()
30 }
25 }
31
26
32 pub fn new_v1<OnDisk>(
27 pub fn new_v1<OnDisk>(
@@ -40,16 +35,12 impl OwningDirstateMap {
40 let mut parents = DirstateParents::NULL;
35 let mut parents = DirstateParents::NULL;
41
36
42 Ok((
37 Ok((
43 OwningDirstateMapTryBuilder {
38 OwningDirstateMap::try_new(on_disk, |bytes| {
44 on_disk,
45 map_builder: |bytes| {
46 DirstateMap::new_v1(bytes, identity).map(|(dmap, p)| {
39 DirstateMap::new_v1(bytes, identity).map(|(dmap, p)| {
47 parents = p.unwrap_or(DirstateParents::NULL);
40 parents = p.unwrap_or(DirstateParents::NULL);
48 dmap
41 dmap
49 })
42 })
50 },
43 })?,
51 }
52 .try_build()?,
53 parents,
44 parents,
54 ))
45 ))
55 }
46 }
@@ -66,28 +57,24 impl OwningDirstateMap {
66 {
57 {
67 let on_disk = Box::new(on_disk);
58 let on_disk = Box::new(on_disk);
68
59
69 OwningDirstateMapTryBuilder {
60 OwningDirstateMap::try_new(on_disk, |bytes| {
70 on_disk,
71 map_builder: |bytes| {
72 DirstateMap::new_v2(bytes, data_size, metadata, uuid, identity)
61 DirstateMap::new_v2(bytes, data_size, metadata, uuid, identity)
73 },
62 })
74 }
75 .try_build()
76 }
63 }
77
64
78 pub fn with_dmap_mut<R>(
65 pub fn with_dmap_mut<R>(
79 &mut self,
66 &mut self,
80 f: impl FnOnce(&mut DirstateMap) -> R,
67 f: impl FnOnce(&mut DirstateMap) -> R,
81 ) -> R {
68 ) -> R {
82 self.with_map_mut(f)
69 self.with_dependent_mut(|_owner, dmap| f(dmap))
83 }
70 }
84
71
85 pub fn get_map(&self) -> &DirstateMap {
72 pub fn get_map(&self) -> &DirstateMap {
86 self.borrow_map()
73 self.borrow_dependent()
87 }
74 }
88
75
89 pub fn on_disk(&self) -> &[u8] {
76 pub fn on_disk(&self) -> &[u8] {
90 self.borrow_on_disk()
77 self.borrow_owner()
91 }
78 }
92
79
93 pub fn old_uuid(&self) -> Option<&[u8]> {
80 pub fn old_uuid(&self) -> Option<&[u8]> {
General Comments 0
You need to be logged in to leave comments. Login now