comparison rust/hg-core/src/dirstate_tree/on_disk.rs @ 51700:7f0cb9ee0534

Backout accidental publication of a large range of revisions I accidentally published 25e7f9dcad0f::bd1483fd7088, this is the inverse.
author Raphaël Gomès <rgomes@octobus.net>
date Tue, 23 Jul 2024 10:02:46 +0200
parents 918ceb5a3d25
children ec7171748350
comparison
equal deleted inserted replaced
51699:bd1483fd7088 51700:7f0cb9ee0534
330 pub(super) fn base_name_start( 330 pub(super) fn base_name_start(
331 &self, 331 &self,
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::from(start); 335 let start = usize::try_from(start)
336 // u32 -> usize, could only panic on a 16-bit CPU
337 .expect("dirstate-v2 base_name_start out of bounds");
336 Ok(start) 338 Ok(start)
337 } else { 339 } else {
338 Err(DirstateV2ParseError::new("not enough bytes for base name")) 340 Err(DirstateV2ParseError::new("not enough bytes for base name"))
339 } 341 }
340 } 342 }
589 T: BytesCast, 591 T: BytesCast,
590 Len: TryInto<usize>, 592 Len: TryInto<usize>,
591 { 593 {
592 // Either `usize::MAX` would result in "out of bounds" error since a single 594 // Either `usize::MAX` would result in "out of bounds" error since a single
593 // `&[u8]` cannot occupy the entire addess space. 595 // `&[u8]` cannot occupy the entire addess space.
594 let start = start.get().try_into().unwrap_or(usize::MAX); 596 let start = start.get().try_into().unwrap_or(std::usize::MAX);
595 let len = len.try_into().unwrap_or(usize::MAX); 597 let len = len.try_into().unwrap_or(std::usize::MAX);
596 let bytes = match on_disk.get(start..) { 598 let bytes = match on_disk.get(start..) {
597 Some(bytes) => bytes, 599 Some(bytes) => bytes,
598 None => { 600 None => {
599 return Err(DirstateV2ParseError::new( 601 return Err(DirstateV2ParseError::new(
600 "not enough bytes from disk", 602 "not enough bytes from disk",