martinvonz created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches.
REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12442 AFFECTED FILES rust/hg-core/src/revlog/changelog.rs rust/hg-core/src/revlog/revlog.rs CHANGE DETAILS diff --git a/rust/hg-core/src/revlog/revlog.rs b/rust/hg-core/src/revlog/revlog.rs --- a/rust/hg-core/src/revlog/revlog.rs +++ b/rust/hg-core/src/revlog/revlog.rs @@ -331,6 +331,10 @@ self.rev } + pub fn node(&self) -> &Node { + &self.hash + } + pub fn uncompressed_len(&self) -> Option<u32> { u32::try_from(self.uncompressed_len).ok() } @@ -339,6 +343,38 @@ self.p1 != NULL_REVISION } + pub fn p1(&self) -> Result<Option<RevlogEntry>, RevlogError> { + if self.p1 == NULL_REVISION { + Ok(None) + } else { + Ok(Some(self.revlog.get_entry(self.p1)?)) + } + } + + pub fn p2(&self) -> Result<Option<RevlogEntry>, RevlogError> { + if self.p2 == NULL_REVISION { + Ok(None) + } else { + Ok(Some(self.revlog.get_entry(self.p1)?)) + } + } + + pub fn p1_rev(&self) -> Option<Revision> { + if self.p1 == NULL_REVISION { + None + } else { + Some(self.p1) + } + } + + pub fn p2_rev(&self) -> Option<Revision> { + if self.p2 == NULL_REVISION { + None + } else { + Some(self.p2) + } + } + pub fn is_cencored(&self) -> bool { (self.flags & REVISION_FLAG_CENSORED) != 0 } diff --git a/rust/hg-core/src/revlog/changelog.rs b/rust/hg-core/src/revlog/changelog.rs --- a/rust/hg-core/src/revlog/changelog.rs +++ b/rust/hg-core/src/revlog/changelog.rs @@ -1,6 +1,6 @@ use crate::errors::HgError; use crate::repo::Repo; -use crate::revlog::revlog::{Revlog, RevlogError}; +use crate::revlog::revlog::{Revlog, RevlogEntry, RevlogError}; use crate::revlog::Revision; use crate::revlog::{Node, NodePrefix}; use crate::utils::hg_path::HgPath; @@ -31,6 +31,15 @@ } /// Return the `ChangelogEntry` of the given revision number. + pub fn entry_for_node( + &self, + node: NodePrefix, + ) -> Result<RevlogEntry, RevlogError> { + let rev = self.revlog.rev_from_node(node)?; + self.revlog.get_entry(rev) + } + + /// Return the `ChangelogEntry` of the given revision number. pub fn data_for_rev( &self, rev: Revision, To: martinvonz, #hg-reviewers Cc: mercurial-patches, mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel