comparison rust/hg-core/src/revlog/mod.rs @ 51442:d2858d97af6c

rust-index: drop offset_override The inline `offsets` value diverge from the one on disk for added value, so the offset_override tricks is not going to work well once we start having the full revlog logic in Rust. We remove it beforehand and align the Rust logic to the Python one (adjusting the segment offset at read time for inline revlog).
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 26 Feb 2024 12:59:57 +0100
parents c3f2a9b55f59
children 59f846fbc11d
comparison
equal deleted inserted replaced
51441:c3f2a9b55f59 51442:d2858d97af6c
27 use zstd; 27 use zstd;
28 28
29 use self::node::{NODE_BYTES_LENGTH, NULL_NODE}; 29 use self::node::{NODE_BYTES_LENGTH, NULL_NODE};
30 use self::nodemap_docket::NodeMapDocket; 30 use self::nodemap_docket::NodeMapDocket;
31 use super::index::Index; 31 use super::index::Index;
32 use super::index::INDEX_ENTRY_SIZE;
32 use super::nodemap::{NodeMap, NodeMapError}; 33 use super::nodemap::{NodeMap, NodeMapError};
33 use crate::errors::HgError; 34 use crate::errors::HgError;
34 use crate::vfs::Vfs; 35 use crate::vfs::Vfs;
35 36
36 /// As noted in revlog.c, revision numbers are actually encoded in 37 /// As noted in revlog.c, revision numbers are actually encoded in
529 } 530 }
530 let index_entry = self 531 let index_entry = self
531 .index 532 .index
532 .get_entry(rev) 533 .get_entry(rev)
533 .ok_or(RevlogError::InvalidRevision)?; 534 .ok_or(RevlogError::InvalidRevision)?;
534 let start = index_entry.offset(); 535 let offset = index_entry.offset();
536 let start = if self.index.is_inline() {
537 offset + ((rev.0 as usize + 1) * INDEX_ENTRY_SIZE)
538 } else {
539 offset
540 };
535 let end = start + index_entry.compressed_len() as usize; 541 let end = start + index_entry.compressed_len() as usize;
536 let data = if self.index.is_inline() { 542 let data = if self.index.is_inline() {
537 self.index.data(start, end) 543 self.index.data(start, end)
538 } else { 544 } else {
539 &self.data()[start..end] 545 &self.data()[start..end]