equal
deleted
inserted
replaced
212 .index |
212 .index |
213 .get_entry(rev) |
213 .get_entry(rev) |
214 .ok_or(RevlogError::InvalidRevision)?; |
214 .ok_or(RevlogError::InvalidRevision)?; |
215 |
215 |
216 let data: Vec<u8> = if delta_chain.is_empty() { |
216 let data: Vec<u8> = if delta_chain.is_empty() { |
217 entry.data()?.into() |
217 entry.data_chunk()?.into() |
218 } else { |
218 } else { |
219 Revlog::build_data_from_deltas(entry, &delta_chain)? |
219 Revlog::build_data_from_deltas(entry, &delta_chain)? |
220 }; |
220 }; |
221 |
221 |
222 if self.check_hash( |
222 if self.check_hash( |
258 #[timed] |
258 #[timed] |
259 fn build_data_from_deltas( |
259 fn build_data_from_deltas( |
260 snapshot: RevlogEntry, |
260 snapshot: RevlogEntry, |
261 deltas: &[RevlogEntry], |
261 deltas: &[RevlogEntry], |
262 ) -> Result<Vec<u8>, RevlogError> { |
262 ) -> Result<Vec<u8>, RevlogError> { |
263 let snapshot = snapshot.data()?; |
263 let snapshot = snapshot.data_chunk()?; |
264 let deltas = deltas |
264 let deltas = deltas |
265 .iter() |
265 .iter() |
266 .rev() |
266 .rev() |
267 .map(RevlogEntry::data) |
267 .map(RevlogEntry::data_chunk) |
268 .collect::<Result<Vec<Cow<'_, [u8]>>, RevlogError>>()?; |
268 .collect::<Result<Vec<Cow<'_, [u8]>>, RevlogError>>()?; |
269 let patches: Vec<_> = |
269 let patches: Vec<_> = |
270 deltas.iter().map(|d| patch::PatchList::new(d)).collect(); |
270 deltas.iter().map(|d| patch::PatchList::new(d)).collect(); |
271 let patch = patch::fold_patch_lists(&patches); |
271 let patch = patch::fold_patch_lists(&patches); |
272 Ok(patch.apply(&snapshot)) |
272 Ok(patch.apply(&snapshot)) |
337 pub fn revision(&self) -> Revision { |
337 pub fn revision(&self) -> Revision { |
338 self.rev |
338 self.rev |
339 } |
339 } |
340 |
340 |
341 /// Extract the data contained in the entry. |
341 /// Extract the data contained in the entry. |
342 pub fn data(&self) -> Result<Cow<'_, [u8]>, RevlogError> { |
342 /// This may be a delta. (See `is_delta`.) |
|
343 fn data_chunk(&self) -> Result<Cow<'_, [u8]>, RevlogError> { |
343 if self.bytes.is_empty() { |
344 if self.bytes.is_empty() { |
344 return Ok(Cow::Borrowed(&[])); |
345 return Ok(Cow::Borrowed(&[])); |
345 } |
346 } |
346 match self.bytes[0] { |
347 match self.bytes[0] { |
347 // Revision data is the entirety of the entry, including this |
348 // Revision data is the entirety of the entry, including this |