rust-revlog: split out method for `rev_from_node` without persistent nodemap stable
authorGeorges Racinet <georges.racinet@octobus.net>
Thu, 30 Mar 2023 10:29:29 +0200
branchstable
changeset 50740 0159b014f3ab
parent 50739 48d9af6bd043
child 50741 bca4037306da
rust-revlog: split out method for `rev_from_node` without persistent nodemap This will make easier for the bug fix that is about to come.
rust/hg-core/src/revlog/mod.rs
--- a/rust/hg-core/src/revlog/mod.rs	Thu Jun 08 00:03:54 2023 -0400
+++ b/rust/hg-core/src/revlog/mod.rs	Thu Mar 30 10:29:29 2023 +0200
@@ -234,11 +234,19 @@
                 .find_bin(&self.index, node)?
                 .ok_or(RevlogError::InvalidRevision);
         }
+        self.rev_from_node_no_persistent_nodemap(node)
+    }
 
-        // Fallback to linear scan when a persistent nodemap is not present.
-        // This happens when the persistent-nodemap experimental feature is not
-        // enabled, or for small revlogs.
-        //
+    /// Same as `rev_from_node`, without using a persistent nodemap
+    ///
+    /// This is used as fallback when a persistent nodemap is not present.
+    /// This happens when the persistent-nodemap experimental feature is not
+    /// enabled, or for small revlogs.
+    fn rev_from_node_no_persistent_nodemap(
+        &self,
+        node: NodePrefix,
+    ) -> Result<Revision, RevlogError> {
+        // Linear scan of the revlog
         // TODO: consider building a non-persistent nodemap in memory to
         // optimize these cases.
         let mut found_by_prefix = None;