[Updated] D11414: rust: Make private the `index` field of the `Revlog` struct
SimonSapin
phabricator at mercurial-scm.org
Thu Sep 16 08:02:21 UTC 2021
Closed by commit rHG6c653d9d41b8: rust: Make private the `index` field of the `Revlog` struct (authored by SimonSapin).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D11414?vs=30244&id=30252
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D11414/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D11414
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
@@ -18,7 +18,7 @@
use crate::errors::HgError;
use crate::repo::Repo;
use crate::revlog::Revision;
-use crate::NULL_REVISION;
+use crate::{Node, NULL_REVISION};
#[derive(derive_more::From)]
pub enum RevlogError {
@@ -51,7 +51,7 @@
/// When index and data are not interleaved: bytes of the revlog index.
/// When index and data are interleaved: bytes of the revlog index and
/// data.
- pub(crate) index: Index,
+ index: Index,
/// When index and data are not interleaved: bytes of the revlog data
data_bytes: Option<Box<dyn Deref<Target = [u8]> + Send>>,
/// When present on disk: the persistent nodemap for this revlog
@@ -119,6 +119,11 @@
self.index.is_empty()
}
+ /// Returns the node ID for the given revision number, if it exists in this revlog
+ pub fn node_from_rev(&self, rev: Revision) -> Option<&Node> {
+ Some(self.index.get_entry(rev)?.hash())
+ }
+
/// Return the full data associated to a node.
#[timed]
pub fn get_node_rev(
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
@@ -36,7 +36,7 @@
}
pub fn node_from_rev(&self, rev: Revision) -> Option<&Node> {
- Some(self.revlog.index.get_entry(rev)?.hash())
+ self.revlog.node_from_rev(rev)
}
}
To: SimonSapin, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210916/c493fb4c/attachment-0002.html>
More information about the Mercurial-patches
mailing list