Mercurial > public > mercurial-scm > hg-stable
comparison rust/hg-core/src/dirstate_tree/owning.rs @ 52078:ea0467ed76aa
rust-dirstate-map: use a more precise identity
This is closer to the behavior of what Python does. So far, we were checking
only the inode, but this might not be good enough for the v1 case.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Thu, 03 Oct 2024 16:35:31 +0200 |
parents | 88aa21d654e5 |
children |
comparison
equal
deleted
inserted
replaced
52077:af54626bf358 | 52078:ea0467ed76aa |
---|---|
1 use crate::{DirstateError, DirstateParents}; | 1 use crate::{DirstateError, DirstateParents}; |
2 | 2 |
3 use super::dirstate_map::DirstateMap; | 3 use super::dirstate_map::{DirstateIdentity, DirstateMap}; |
4 use self_cell::self_cell; | 4 use self_cell::self_cell; |
5 use std::ops::Deref; | 5 use std::ops::Deref; |
6 | 6 |
7 self_cell!( | 7 self_cell!( |
8 /// Keep a `DirstateMap<'owner>` next to the `owner` buffer that it | 8 /// Keep a `DirstateMap<'owner>` next to the `owner` buffer that it |
13 dependent: DirstateMap, | 13 dependent: DirstateMap, |
14 } | 14 } |
15 ); | 15 ); |
16 | 16 |
17 impl OwningDirstateMap { | 17 impl OwningDirstateMap { |
18 pub fn new_empty<OnDisk>(on_disk: OnDisk, identity: Option<u64>) -> Self | 18 pub fn new_empty<OnDisk>( |
19 on_disk: OnDisk, | |
20 identity: Option<DirstateIdentity>, | |
21 ) -> Self | |
19 where | 22 where |
20 OnDisk: Deref<Target = [u8]> + Send + 'static, | 23 OnDisk: Deref<Target = [u8]> + Send + 'static, |
21 { | 24 { |
22 let on_disk = Box::new(on_disk); | 25 let on_disk = Box::new(on_disk); |
23 | 26 |
28 }) | 31 }) |
29 } | 32 } |
30 | 33 |
31 pub fn new_v1<OnDisk>( | 34 pub fn new_v1<OnDisk>( |
32 on_disk: OnDisk, | 35 on_disk: OnDisk, |
33 identity: Option<u64>, | 36 identity: Option<DirstateIdentity>, |
34 ) -> Result<(Self, DirstateParents), DirstateError> | 37 ) -> Result<(Self, DirstateParents), DirstateError> |
35 where | 38 where |
36 OnDisk: Deref<Target = [u8]> + Send + 'static, | 39 OnDisk: Deref<Target = [u8]> + Send + 'static, |
37 { | 40 { |
38 let on_disk = Box::new(on_disk); | 41 let on_disk = Box::new(on_disk); |
52 pub fn new_v2<OnDisk>( | 55 pub fn new_v2<OnDisk>( |
53 on_disk: OnDisk, | 56 on_disk: OnDisk, |
54 data_size: usize, | 57 data_size: usize, |
55 metadata: &[u8], | 58 metadata: &[u8], |
56 uuid: Vec<u8>, | 59 uuid: Vec<u8>, |
57 identity: Option<u64>, | 60 identity: Option<DirstateIdentity>, |
58 ) -> Result<Self, DirstateError> | 61 ) -> Result<Self, DirstateError> |
59 where | 62 where |
60 OnDisk: Deref<Target = [u8]> + Send + 'static, | 63 OnDisk: Deref<Target = [u8]> + Send + 'static, |
61 { | 64 { |
62 let on_disk = Box::new(on_disk); | 65 let on_disk = Box::new(on_disk); |
83 | 86 |
84 pub fn old_uuid(&self) -> Option<&[u8]> { | 87 pub fn old_uuid(&self) -> Option<&[u8]> { |
85 self.get_map().old_uuid.as_deref() | 88 self.get_map().old_uuid.as_deref() |
86 } | 89 } |
87 | 90 |
88 pub fn old_identity(&self) -> Option<u64> { | 91 pub fn old_identity(&self) -> Option<DirstateIdentity> { |
89 self.get_map().identity | 92 self.get_map().identity |
90 } | 93 } |
91 | 94 |
92 pub fn old_data_size(&self) -> usize { | 95 pub fn old_data_size(&self) -> usize { |
93 self.get_map().old_data_size | 96 self.get_map().old_data_size |