rust: Rename get_node methods to data_for_node, get_rev to data_for_rev
These are respective methods of Changelog, Manifestlog, and Filelog;
three Rust structs that that wrap a Revlog struct.
This rename clarifies that node IDs or revision numbers are parameters,
not return values.
Also reword doc-comments in Manifestlog and Filelog to separate node IDs
and revision numbers that are local to a given (non-changelog) revlog
from those of a changeset.
Differential Revision: https://phab.mercurial-scm.org/D11416
--- a/rust/hg-core/src/operations/cat.rs Tue Sep 14 18:10:35 2021 +0200
+++ b/rust/hg-core/src/operations/cat.rs Tue Sep 14 18:25:51 2021 +0200
@@ -50,7 +50,7 @@
found_any = true;
let file_log = repo.filelog(manifest_file)?;
let file_node = Node::from_hex_for_repo(node_bytes)?;
- let entry = file_log.get_node(file_node)?;
+ let entry = file_log.data_for_node(file_node)?;
bytes.extend(entry.data()?)
}
}
--- a/rust/hg-core/src/repo.rs Tue Sep 14 18:10:35 2021 +0200
+++ b/rust/hg-core/src/repo.rs Tue Sep 14 18:25:51 2021 +0200
@@ -336,26 +336,29 @@
self.manifestlog.get_mut_or_init(self)
}
- /// Returns the manifest of the given node ID
+ /// Returns the manifest of the *changeset* with the given node ID
pub fn manifest_for_node(
&self,
node: impl Into<NodePrefix>,
) -> Result<Manifest, RevlogError> {
- self.manifestlog()?.get_node(
+ self.manifestlog()?.data_for_node(
self.changelog()?
- .get_node(node.into())?
+ .data_for_node(node.into())?
.manifest_node()?
.into(),
)
}
- /// Returns the manifest of the given revision
+ /// Returns the manifest of the *changeset* with the given revision number
pub fn manifest_for_rev(
&self,
revision: Revision,
) -> Result<Manifest, RevlogError> {
- self.manifestlog()?.get_node(
- self.changelog()?.get_rev(revision)?.manifest_node()?.into(),
+ self.manifestlog()?.data_for_node(
+ self.changelog()?
+ .data_for_rev(revision)?
+ .manifest_node()?
+ .into(),
)
}
--- a/rust/hg-core/src/revlog/changelog.rs Tue Sep 14 18:10:35 2021 +0200
+++ b/rust/hg-core/src/revlog/changelog.rs Tue Sep 14 18:25:51 2021 +0200
@@ -17,17 +17,17 @@
Ok(Self { revlog })
}
- /// Return the `ChangelogEntry` a given node id.
- pub fn get_node(
+ /// Return the `ChangelogEntry` for the given node ID.
+ pub fn data_for_node(
&self,
node: NodePrefix,
) -> Result<ChangelogEntry, RevlogError> {
let rev = self.revlog.rev_from_node(node)?;
- self.get_rev(rev)
+ self.data_for_rev(rev)
}
- /// Return the `ChangelogEntry` of a given node revision.
- pub fn get_rev(
+ /// Return the `ChangelogEntry` of the given revision number.
+ pub fn data_for_rev(
&self,
rev: Revision,
) -> Result<ChangelogEntry, RevlogError> {
--- a/rust/hg-core/src/revlog/filelog.rs Tue Sep 14 18:10:35 2021 +0200
+++ b/rust/hg-core/src/revlog/filelog.rs Tue Sep 14 18:25:51 2021 +0200
@@ -26,17 +26,17 @@
/// The given node ID is that of the file as found in a manifest, not of a
/// changeset.
- pub fn get_node(
+ pub fn data_for_node(
&self,
file_node: impl Into<NodePrefix>,
) -> Result<FilelogEntry, RevlogError> {
let file_rev = self.revlog.rev_from_node(file_node.into())?;
- self.get_rev(file_rev)
+ self.data_for_rev(file_rev)
}
/// The given revision is that of the file as found in a manifest, not of a
/// changeset.
- pub fn get_rev(
+ pub fn data_for_rev(
&self,
file_rev: Revision,
) -> Result<FilelogEntry, RevlogError> {
--- a/rust/hg-core/src/revlog/manifest.rs Tue Sep 14 18:10:35 2021 +0200
+++ b/rust/hg-core/src/revlog/manifest.rs Tue Sep 14 18:25:51 2021 +0200
@@ -18,14 +18,31 @@
Ok(Self { revlog })
}
- /// Return the `ManifestEntry` of a given node id.
- pub fn get_node(&self, node: NodePrefix) -> Result<Manifest, RevlogError> {
+ /// Return the `Manifest` for the given node ID.
+ ///
+ /// Note: this is a node ID in the manifestlog, typically found through
+ /// `ChangelogEntry::manifest_node`. It is *not* the node ID of any
+ /// changeset.
+ ///
+ /// See also `Repo::manifest_for_node`
+ pub fn data_for_node(
+ &self,
+ node: NodePrefix,
+ ) -> Result<Manifest, RevlogError> {
let rev = self.revlog.rev_from_node(node)?;
- self.get_rev(rev)
+ self.data_for_rev(rev)
}
- /// Return the `ManifestEntry` of a given node revision.
- pub fn get_rev(&self, rev: Revision) -> Result<Manifest, RevlogError> {
+ /// Return the `Manifest` of a given revision number.
+ ///
+ /// Note: this is a revision number in the manifestlog, *not* of any
+ /// changeset.
+ ///
+ /// See also `Repo::manifest_for_rev`
+ pub fn data_for_rev(
+ &self,
+ rev: Revision,
+ ) -> Result<Manifest, RevlogError> {
let bytes = self.revlog.get_rev_data(rev)?;
Ok(Manifest { bytes })
}
--- a/rust/hg-core/src/revlog/revlog.rs Tue Sep 14 18:10:35 2021 +0200
+++ b/rust/hg-core/src/revlog/revlog.rs Tue Sep 14 18:25:51 2021 +0200
@@ -119,12 +119,14 @@
self.index.is_empty()
}
- /// Returns the node ID for the given revision number, if it exists in this revlog
+ /// 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 revision number for the given node ID, if it exists in this revlog
+ /// Return the revision number for the given node ID, if it exists in this
+ /// revlog
#[timed]
pub fn rev_from_node(
&self,
--- a/rust/rhg/src/commands/status.rs Tue Sep 14 18:10:35 2021 +0200
+++ b/rust/rhg/src/commands/status.rs Tue Sep 14 18:25:51 2021 +0200
@@ -270,7 +270,7 @@
.find_file(hg_path)?
.expect("ambgious file not in p1");
let filelog = repo.filelog(hg_path)?;
- let filelog_entry = filelog.get_node(file_node).map_err(|_| {
+ let filelog_entry = filelog.data_for_node(file_node).map_err(|_| {
HgError::corrupted("filelog missing node from manifest")
})?;
let contents_in_p1 = filelog_entry.data()?;