rust-revlog: split logic for `rawdata` to prepare for `UncheckedRevision` use
authorRaphaël Gomès <rgomes@octobus.net>
Mon, 11 Sep 2023 11:52:33 +0200
changeset 50976 9929c8a73488
parent 50975 3aca98a35727
child 50977 1928b770e3e7
rust-revlog: split logic for `rawdata` to prepare for `UncheckedRevision` use In the next changeset, we will change the logic to use `UncheckedRevision` in the non-general delta case. The general delta case will use the "checked" path since `base_rev_or_base_of_delta_chain` will be checked.
rust/hg-core/src/revlog/mod.rs
--- a/rust/hg-core/src/revlog/mod.rs	Mon Aug 07 15:07:48 2023 +0200
+++ b/rust/hg-core/src/revlog/mod.rs	Mon Sep 11 11:52:33 2023 +0200
@@ -537,13 +537,14 @@
         // [_chaininfo] and in [index_deltachain].
         let uses_generaldelta = self.revlog.index.uses_generaldelta();
         while let Some(base_rev) = entry.base_rev_or_base_of_delta_chain {
-            let base_rev = if uses_generaldelta {
-                base_rev
+            entry = if uses_generaldelta {
+                delta_chain.push(entry);
+                self.revlog.get_entry_internal(base_rev)?
             } else {
-                entry.rev - 1
+                let base_rev = entry.rev - 1;
+                delta_chain.push(entry);
+                self.revlog.get_entry_internal(base_rev)?
             };
-            delta_chain.push(entry);
-            entry = self.revlog.get_entry_internal(base_rev)?;
         }
 
         let data = if delta_chain.is_empty() {