Show More
@@ -427,19 +427,14 b" pub(super) struct Node<'on_disk> {" | |||||
427 | pub(super) tracked_descendants_count: u32, |
|
427 | pub(super) tracked_descendants_count: u32, | |
428 | } |
|
428 | } | |
429 |
|
429 | |||
430 | #[derive(Debug)] |
|
430 | #[derive(Debug, Default)] | |
431 | pub(super) enum NodeData { |
|
431 | pub(super) enum NodeData { | |
432 | Entry(DirstateEntry), |
|
432 | Entry(DirstateEntry), | |
433 | CachedDirectory { mtime: TruncatedTimestamp }, |
|
433 | CachedDirectory { mtime: TruncatedTimestamp }, | |
|
434 | #[default] | |||
434 | None, |
|
435 | None, | |
435 | } |
|
436 | } | |
436 |
|
437 | |||
437 | impl Default for NodeData { |
|
|||
438 | fn default() -> Self { |
|
|||
439 | NodeData::None |
|
|||
440 | } |
|
|||
441 | } |
|
|||
442 |
|
||||
443 | impl NodeData { |
|
438 | impl NodeData { | |
444 | fn has_entry(&self) -> bool { |
|
439 | fn has_entry(&self) -> bool { | |
445 | matches!(self, NodeData::Entry(_)) |
|
440 | matches!(self, NodeData::Entry(_)) |
@@ -332,9 +332,7 b' impl Node {' | |||||
332 | ) -> Result<usize, DirstateV2ParseError> { |
|
332 | ) -> Result<usize, DirstateV2ParseError> { | |
333 | let start = self.base_name_start.get(); |
|
333 | let start = self.base_name_start.get(); | |
334 | if start < self.full_path.len.get() { |
|
334 | if start < self.full_path.len.get() { | |
335 |
let start = usize:: |
|
335 | let start = usize::from(start); | |
336 | // u32 -> usize, could only panic on a 16-bit CPU |
|
|||
337 | .expect("dirstate-v2 base_name_start out of bounds"); |
|
|||
338 | Ok(start) |
|
336 | Ok(start) | |
339 | } else { |
|
337 | } else { | |
340 | Err(DirstateV2ParseError::new("not enough bytes for base name")) |
|
338 | Err(DirstateV2ParseError::new("not enough bytes for base name")) | |
@@ -593,8 +591,8 b' where' | |||||
593 | { |
|
591 | { | |
594 | // Either `usize::MAX` would result in "out of bounds" error since a single |
|
592 | // Either `usize::MAX` would result in "out of bounds" error since a single | |
595 | // `&[u8]` cannot occupy the entire addess space. |
|
593 | // `&[u8]` cannot occupy the entire addess space. | |
596 |
let start = start.get().try_into().unwrap_or( |
|
594 | let start = start.get().try_into().unwrap_or(usize::MAX); | |
597 |
let len = len.try_into().unwrap_or( |
|
595 | let len = len.try_into().unwrap_or(usize::MAX); | |
598 | let bytes = match on_disk.get(start..) { |
|
596 | let bytes = match on_disk.get(start..) { | |
599 | Some(bytes) => bytes, |
|
597 | Some(bytes) => bytes, | |
600 | None => { |
|
598 | None => { |
@@ -617,7 +617,11 b' impl IntersectionMatcher {' | |||||
617 | std::mem::swap(&mut m1, &mut m2); |
|
617 | std::mem::swap(&mut m1, &mut m2); | |
618 | } |
|
618 | } | |
619 | m1.file_set().map(|m1_files| { |
|
619 | m1.file_set().map(|m1_files| { | |
620 | m1_files.iter().cloned().filter(|f| m2.matches(f)).collect() |
|
620 | m1_files | |
|
621 | .iter() | |||
|
622 | .filter(|&f| m2.matches(f)) | |||
|
623 | .cloned() | |||
|
624 | .collect() | |||
621 | }) |
|
625 | }) | |
622 | } else { |
|
626 | } else { | |
623 | // without exact input file sets, we can't do an exact |
|
627 | // without exact input file sets, we can't do an exact | |
@@ -710,7 +714,7 b' impl DifferenceMatcher {' | |||||
710 | }; |
|
714 | }; | |
711 | if base_is_exact { |
|
715 | if base_is_exact { | |
712 | new.files = base_files.map(|files| { |
|
716 | new.files = base_files.map(|files| { | |
713 |
files.iter(). |
|
717 | files.iter().filter(|&f| new.matches(f)).cloned().collect() | |
714 | }); |
|
718 | }); | |
715 | } |
|
719 | } | |
716 | new |
|
720 | new |
@@ -617,7 +617,7 b' message",' | |||||
617 | #[test] |
|
617 | #[test] | |
618 | fn test_unescape_nul_followed_by_octal() { |
|
618 | fn test_unescape_nul_followed_by_octal() { | |
619 | // Escaped NUL chars followed by octal digits are decoded correctly. |
|
619 | // Escaped NUL chars followed by octal digits are decoded correctly. | |
620 | let expected = b"\012"; |
|
620 | let expected = b"\x0012"; | |
621 | let escaped = br"\012"; |
|
621 | let escaped = br"\012"; | |
622 | let unescaped = unescape_extra(escaped); |
|
622 | let unescaped = unescape_extra(escaped); | |
623 | assert_eq!(&expected[..], &unescaped[..]); |
|
623 | assert_eq!(&expected[..], &unescaped[..]); | |
@@ -713,7 +713,7 b' message",' | |||||
713 |
|
713 | |||
714 | for (extra, msg) in test_cases { |
|
714 | for (extra, msg) in test_cases { | |
715 | assert!( |
|
715 | assert!( | |
716 |
decode_extra( |
|
716 | decode_extra(extra).is_err(), | |
717 | "corrupt extra should have failed to parse: {}", |
|
717 | "corrupt extra should have failed to parse: {}", | |
718 | msg |
|
718 | msg | |
719 | ); |
|
719 | ); |
@@ -1387,6 +1387,7 b' trait PoisonableBitSet: Sized + PartialE' | |||||
1387 | fn vec_of_empty(sets_size: usize, vec_len: usize) -> Vec<Self>; |
|
1387 | fn vec_of_empty(sets_size: usize, vec_len: usize) -> Vec<Self>; | |
1388 |
|
1388 | |||
1389 | /// The size of the bit mask in memory |
|
1389 | /// The size of the bit mask in memory | |
|
1390 | #[allow(unused)] | |||
1390 | fn size(&self) -> usize; |
|
1391 | fn size(&self) -> usize; | |
1391 |
|
1392 | |||
1392 | /// The number of elements that can be represented in the set. |
|
1393 | /// The number of elements that can be represented in the set. | |
@@ -1394,12 +1395,14 b' trait PoisonableBitSet: Sized + PartialE' | |||||
1394 | /// Another way to put it is that it is the highest integer `C` such that |
|
1395 | /// Another way to put it is that it is the highest integer `C` such that | |
1395 | /// the set is guaranteed to always be a subset of the integer range |
|
1396 | /// the set is guaranteed to always be a subset of the integer range | |
1396 | /// `[0, C)` |
|
1397 | /// `[0, C)` | |
|
1398 | #[allow(unused)] | |||
1397 | fn capacity(&self) -> usize; |
|
1399 | fn capacity(&self) -> usize; | |
1398 |
|
1400 | |||
1399 | /// Declare `n` to belong to the set |
|
1401 | /// Declare `n` to belong to the set | |
1400 | fn add(&mut self, n: usize); |
|
1402 | fn add(&mut self, n: usize); | |
1401 |
|
1403 | |||
1402 | /// Declare `n` not to belong to the set |
|
1404 | /// Declare `n` not to belong to the set | |
|
1405 | #[allow(unused)] | |||
1403 | fn discard(&mut self, n: usize); |
|
1406 | fn discard(&mut self, n: usize); | |
1404 |
|
1407 | |||
1405 | /// Replace this bit set by its union with other |
|
1408 | /// Replace this bit set by its union with other | |
@@ -1749,6 +1752,9 b" impl<'a> IndexEntry<'a> {" | |||||
1749 | } |
|
1752 | } | |
1750 |
|
1753 | |||
1751 | #[cfg(test)] |
|
1754 | #[cfg(test)] | |
|
1755 | pub use tests::IndexEntryBuilder; | |||
|
1756 | ||||
|
1757 | #[cfg(test)] | |||
1752 | mod tests { |
|
1758 | mod tests { | |
1753 | use super::*; |
|
1759 | use super::*; | |
1754 | use crate::node::NULL_NODE; |
|
1760 | use crate::node::NULL_NODE; | |
@@ -2027,6 +2033,3 b' mod tests {' | |||||
2027 | assert_eq!(get_version(&bytes), 2) |
|
2033 | assert_eq!(get_version(&bytes), 2) | |
2028 | } |
|
2034 | } | |
2029 | } |
|
2035 | } | |
2030 |
|
||||
2031 | #[cfg(test)] |
|
|||
2032 | pub use tests::IndexEntryBuilder; |
|
@@ -83,7 +83,7 b" impl<'a> TryFrom<&'a [u8]> for &'a Node " | |||||
83 | #[inline] |
|
83 | #[inline] | |
84 | fn try_from(bytes: &'a [u8]) -> Result<Self, Self::Error> { |
|
84 | fn try_from(bytes: &'a [u8]) -> Result<Self, Self::Error> { | |
85 | match Node::from_bytes(bytes) { |
|
85 | match Node::from_bytes(bytes) { | |
86 |
Ok((node, |
|
86 | Ok((node, [])) => Ok(node), | |
87 | _ => Err(()), |
|
87 | _ => Err(()), | |
88 | } |
|
88 | } | |
89 | } |
|
89 | } | |
@@ -323,6 +323,9 b' impl PartialEq<Node> for NodePrefix {' | |||||
323 | } |
|
323 | } | |
324 |
|
324 | |||
325 | #[cfg(test)] |
|
325 | #[cfg(test)] | |
|
326 | pub use tests::hex_pad_right; | |||
|
327 | ||||
|
328 | #[cfg(test)] | |||
326 | mod tests { |
|
329 | mod tests { | |
327 | use super::*; |
|
330 | use super::*; | |
328 |
|
331 | |||
@@ -428,6 +431,3 b' mod tests {' | |||||
428 | assert_eq!(prefix.first_different_nybble(&node), None); |
|
431 | assert_eq!(prefix.first_different_nybble(&node), None); | |
429 | } |
|
432 | } | |
430 | } |
|
433 | } | |
431 |
|
||||
432 | #[cfg(test)] |
|
|||
433 | pub use tests::hex_pad_right; |
|
@@ -69,6 +69,7 b' fn ancestors_sets(vg: &VecGraph) -> Vec<' | |||||
69 | ancs |
|
69 | ancs | |
70 | } |
|
70 | } | |
71 |
|
71 | |||
|
72 | #[allow(unused)] // Useful when debugging | |||
72 | #[derive(Clone, Debug)] |
|
73 | #[derive(Clone, Debug)] | |
73 | enum MissingAncestorsAction { |
|
74 | enum MissingAncestorsAction { | |
74 | InitialBases(HashSet<Revision>), |
|
75 | InitialBases(HashSet<Revision>), |
General Comments 0
You need to be logged in to leave comments.
Login now