rust/hg-core/src/revlog/index.rs
changeset 48543 0a4ac916673e
parent 48458 96ea4db4741b
child 48546 e91aa800ae5b
equal deleted inserted replaced
48542:35c47015b9b7 48543:0a4ac916673e
   116                 let entry = IndexEntry {
   116                 let entry = IndexEntry {
   117                     bytes: &bytes[offset..end],
   117                     bytes: &bytes[offset..end],
   118                     offset_override: None,
   118                     offset_override: None,
   119                 };
   119                 };
   120 
   120 
   121                 offset += INDEX_ENTRY_SIZE + entry.compressed_len();
   121                 offset += INDEX_ENTRY_SIZE + entry.compressed_len() as usize;
   122             }
   122             }
   123 
   123 
   124             if offset == bytes.len() {
   124             if offset == bytes.len() {
   125                 Ok(Self {
   125                 Ok(Self {
   126                     bytes,
   126                     bytes,
   259             BigEndian::read_u64(&bytes[..]) as usize
   259             BigEndian::read_u64(&bytes[..]) as usize
   260         }
   260         }
   261     }
   261     }
   262 
   262 
   263     /// Return the compressed length of the data.
   263     /// Return the compressed length of the data.
   264     pub fn compressed_len(&self) -> usize {
   264     pub fn compressed_len(&self) -> u32 {
   265         BigEndian::read_u32(&self.bytes[8..=11]) as usize
   265         BigEndian::read_u32(&self.bytes[8..=11])
   266     }
   266     }
   267 
   267 
   268     /// Return the uncompressed length of the data.
   268     /// Return the uncompressed length of the data.
   269     pub fn uncompressed_len(&self) -> usize {
   269     pub fn uncompressed_len(&self) -> i32 {
   270         BigEndian::read_u32(&self.bytes[12..=15]) as usize
   270         BigEndian::read_i32(&self.bytes[12..=15])
   271     }
   271     }
   272 
   272 
   273     /// Return the revision upon which the data has been derived.
   273     /// Return the revision upon which the data has been derived.
   274     pub fn base_revision_or_base_of_delta_chain(&self) -> Revision {
   274     pub fn base_revision_or_base_of_delta_chain(&self) -> Revision {
   275         // TODO Maybe return an Option when base_revision == rev?
   275         // TODO Maybe return an Option when base_revision == rev?