[Updated] D11416: rust: Rename get_node methods to data_for_node, get_rev to data_for_rev
SimonSapin
phabricator at mercurial-scm.org
Thu Sep 16 08:03:41 UTC 2021
Closed by commit rHG87e3f878e65f: rust: Rename get_node methods to data_for_node, get_rev to data_for_rev (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/D11416?vs=30246&id=30254
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D11416/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D11416
AFFECTED FILES
rust/hg-core/src/operations/cat.rs
rust/hg-core/src/repo.rs
rust/hg-core/src/revlog/changelog.rs
rust/hg-core/src/revlog/filelog.rs
rust/hg-core/src/revlog/manifest.rs
rust/hg-core/src/revlog/revlog.rs
rust/rhg/src/commands/status.rs
CHANGE DETAILS
diff --git a/rust/rhg/src/commands/status.rs b/rust/rhg/src/commands/status.rs
--- a/rust/rhg/src/commands/status.rs
+++ b/rust/rhg/src/commands/status.rs
@@ -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()?;
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
@@ -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,
diff --git a/rust/hg-core/src/revlog/manifest.rs b/rust/hg-core/src/revlog/manifest.rs
--- a/rust/hg-core/src/revlog/manifest.rs
+++ b/rust/hg-core/src/revlog/manifest.rs
@@ -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 })
}
diff --git a/rust/hg-core/src/revlog/filelog.rs b/rust/hg-core/src/revlog/filelog.rs
--- a/rust/hg-core/src/revlog/filelog.rs
+++ b/rust/hg-core/src/revlog/filelog.rs
@@ -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> {
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
@@ -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> {
diff --git a/rust/hg-core/src/repo.rs b/rust/hg-core/src/repo.rs
--- a/rust/hg-core/src/repo.rs
+++ b/rust/hg-core/src/repo.rs
@@ -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(),
)
}
diff --git a/rust/hg-core/src/operations/cat.rs b/rust/hg-core/src/operations/cat.rs
--- a/rust/hg-core/src/operations/cat.rs
+++ b/rust/hg-core/src/operations/cat.rs
@@ -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()?)
}
}
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/ba7a56ff/attachment-0002.html>
More information about the Mercurial-patches
mailing list