diff rust/hg-core/src/revlog/changelog.rs @ 52290:a3fa37bdb7ec

rust: normalize `_for_unchecked_rev` naming among revlogs and the index This normalizes the naming scheme between the `Revlog`, `Changelog`, etc. which is less suprising, though no real bugs could stem from this because of the type signature mismatch. The very high-level `Repo` object still uses an `UncheckedRevision` parameter for its methods because that's what most callers will want.
author Rapha?l Gom?s <rgomes@octobus.net>
date Tue, 29 Oct 2024 11:00:04 +0100
parents 7be39c5110c9
children 169ccd142ef8
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/changelog.rs	Tue Nov 12 12:45:23 2024 +0100
+++ b/rust/hg-core/src/revlog/changelog.rs	Tue Oct 29 11:00:04 2024 +0100
@@ -40,24 +40,21 @@
         node: NodePrefix,
     ) -> Result<ChangelogRevisionData, RevlogError> {
         let rev = self.revlog.rev_from_node(node)?;
-        self.entry_for_checked_rev(rev)?.data()
+        self.entry(rev)?.data()
     }
 
     /// Return the [`ChangelogEntry`] for the given revision number.
-    pub fn entry_for_rev(
+    pub fn entry_for_unchecked_rev(
         &self,
         rev: UncheckedRevision,
     ) -> Result<ChangelogEntry, RevlogError> {
-        let revlog_entry = self.revlog.get_entry(rev)?;
+        let revlog_entry = self.revlog.get_entry_for_unchecked_rev(rev)?;
         Ok(ChangelogEntry { revlog_entry })
     }
 
-    /// Same as [`Self::entry_for_rev`] for checked revisions.
-    fn entry_for_checked_rev(
-        &self,
-        rev: Revision,
-    ) -> Result<ChangelogEntry, RevlogError> {
-        let revlog_entry = self.revlog.get_entry_for_checked_rev(rev)?;
+    /// Same as [`Self::entry_for_unchecked_rev`] for a checked revision
+    fn entry(&self, rev: Revision) -> Result<ChangelogEntry, RevlogError> {
+        let revlog_entry = self.revlog.get_entry(rev)?;
         Ok(ChangelogEntry { revlog_entry })
     }
 
@@ -66,15 +63,18 @@
     /// This is a useful shortcut in case the caller does not need the
     /// generic revlog information (parents, hashes etc). Otherwise
     /// consider taking a [`ChangelogEntry`] with
-    /// [entry_for_rev](`Self::entry_for_rev`) and doing everything from there.
-    pub fn data_for_rev(
+    /// [`Self::entry_for_unchecked_rev`] and doing everything from there.
+    pub fn data_for_unchecked_rev(
         &self,
         rev: UncheckedRevision,
     ) -> Result<ChangelogRevisionData, RevlogError> {
-        self.entry_for_rev(rev)?.data()
+        self.entry_for_unchecked_rev(rev)?.data()
     }
 
-    pub fn node_from_rev(&self, rev: UncheckedRevision) -> Option<&Node> {
+    pub fn node_from_unchecked_rev(
+        &self,
+        rev: UncheckedRevision,
+    ) -> Option<&Node> {
         self.revlog.node_from_rev(rev)
     }
 
@@ -570,12 +570,14 @@
 
         let changelog = Changelog { revlog };
         assert_eq!(
-            changelog.data_for_rev(NULL_REVISION.into())?,
+            changelog.data_for_unchecked_rev(NULL_REVISION.into())?,
             ChangelogRevisionData::null()
         );
         // same with the intermediate entry object
         assert_eq!(
-            changelog.entry_for_rev(NULL_REVISION.into())?.data()?,
+            changelog
+                .entry_for_unchecked_rev(NULL_REVISION.into())?
+                .data()?,
             ChangelogRevisionData::null()
         );
         Ok(())