Show More
@@ -1,6 +1,6 b'' | |||||
1 | use crate::errors::HgError; |
|
1 | use crate::errors::HgError; | |
2 | use crate::repo::Repo; |
|
2 | use crate::repo::Repo; | |
3 | use crate::revlog::revlog::{Revlog, RevlogError}; |
|
3 | use crate::revlog::revlog::{Revlog, RevlogEntry, RevlogError}; | |
4 | use crate::revlog::Revision; |
|
4 | use crate::revlog::Revision; | |
5 | use crate::revlog::{Node, NodePrefix}; |
|
5 | use crate::revlog::{Node, NodePrefix}; | |
6 | use crate::utils::hg_path::HgPath; |
|
6 | use crate::utils::hg_path::HgPath; | |
@@ -30,6 +30,14 b' impl Changelog {' | |||||
30 | self.data_for_rev(rev) |
|
30 | self.data_for_rev(rev) | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
|
33 | /// Return the `RevlogEntry` of the given revision number. | |||
|
34 | pub fn entry_for_rev( | |||
|
35 | &self, | |||
|
36 | rev: Revision, | |||
|
37 | ) -> Result<RevlogEntry, RevlogError> { | |||
|
38 | self.revlog.get_entry(rev) | |||
|
39 | } | |||
|
40 | ||||
33 | /// Return the `ChangelogEntry` of the given revision number. |
|
41 | /// Return the `ChangelogEntry` of the given revision number. | |
34 | pub fn data_for_rev( |
|
42 | pub fn data_for_rev( | |
35 | &self, |
|
43 | &self, | |
@@ -51,6 +59,13 b' impl Changelog {' | |||||
51 | pub fn node_from_rev(&self, rev: Revision) -> Option<&Node> { |
|
59 | pub fn node_from_rev(&self, rev: Revision) -> Option<&Node> { | |
52 | self.revlog.node_from_rev(rev) |
|
60 | self.revlog.node_from_rev(rev) | |
53 | } |
|
61 | } | |
|
62 | ||||
|
63 | pub fn rev_from_node( | |||
|
64 | &self, | |||
|
65 | node: NodePrefix, | |||
|
66 | ) -> Result<Revision, RevlogError> { | |||
|
67 | self.revlog.rev_from_node(node) | |||
|
68 | } | |||
54 | } |
|
69 | } | |
55 |
|
70 | |||
56 | /// `Changelog` entry which knows how to interpret the `changelog` data bytes. |
|
71 | /// `Changelog` entry which knows how to interpret the `changelog` data bytes. |
@@ -331,6 +331,10 b" impl<'a> RevlogEntry<'a> {" | |||||
331 | self.rev |
|
331 | self.rev | |
332 | } |
|
332 | } | |
333 |
|
333 | |||
|
334 | pub fn node(&self) -> &Node { | |||
|
335 | &self.hash | |||
|
336 | } | |||
|
337 | ||||
334 | pub fn uncompressed_len(&self) -> Option<u32> { |
|
338 | pub fn uncompressed_len(&self) -> Option<u32> { | |
335 | u32::try_from(self.uncompressed_len).ok() |
|
339 | u32::try_from(self.uncompressed_len).ok() | |
336 | } |
|
340 | } | |
@@ -339,6 +343,38 b" impl<'a> RevlogEntry<'a> {" | |||||
339 | self.p1 != NULL_REVISION |
|
343 | self.p1 != NULL_REVISION | |
340 | } |
|
344 | } | |
341 |
|
345 | |||
|
346 | pub fn p1_entry(&self) -> Result<Option<RevlogEntry>, RevlogError> { | |||
|
347 | if self.p1 == NULL_REVISION { | |||
|
348 | Ok(None) | |||
|
349 | } else { | |||
|
350 | Ok(Some(self.revlog.get_entry(self.p1)?)) | |||
|
351 | } | |||
|
352 | } | |||
|
353 | ||||
|
354 | pub fn p2_entry(&self) -> Result<Option<RevlogEntry>, RevlogError> { | |||
|
355 | if self.p2 == NULL_REVISION { | |||
|
356 | Ok(None) | |||
|
357 | } else { | |||
|
358 | Ok(Some(self.revlog.get_entry(self.p2)?)) | |||
|
359 | } | |||
|
360 | } | |||
|
361 | ||||
|
362 | pub fn p1(&self) -> Option<Revision> { | |||
|
363 | if self.p1 == NULL_REVISION { | |||
|
364 | None | |||
|
365 | } else { | |||
|
366 | Some(self.p1) | |||
|
367 | } | |||
|
368 | } | |||
|
369 | ||||
|
370 | pub fn p2(&self) -> Option<Revision> { | |||
|
371 | if self.p2 == NULL_REVISION { | |||
|
372 | None | |||
|
373 | } else { | |||
|
374 | Some(self.p2) | |||
|
375 | } | |||
|
376 | } | |||
|
377 | ||||
342 | pub fn is_cencored(&self) -> bool { |
|
378 | pub fn is_cencored(&self) -> bool { | |
343 | (self.flags & REVISION_FLAG_CENSORED) != 0 |
|
379 | (self.flags & REVISION_FLAG_CENSORED) != 0 | |
344 | } |
|
380 | } |
General Comments 0
You need to be logged in to leave comments.
Login now