diff rust/hg-core/src/revlog/changelog.rs @ 51906:db7dbe6f7bb2

rust: add Vfs trait This will allow for the use of multiple vfs like in the Python implementation, as well as hiding the details of the upcoming Python vfs wrapper to hg-core.
author Rapha?l Gom?s <rgomes@octobus.net>
date Wed, 19 Jun 2024 14:49:35 +0200
parents 69b804c8e09e
children 1d6982827c4b
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/changelog.rs	Wed Jun 19 12:49:26 2024 +0200
+++ b/rust/hg-core/src/revlog/changelog.rs	Wed Jun 19 14:49:35 2024 +0200
@@ -13,7 +13,7 @@
 use crate::revlog::{Node, NodePrefix};
 use crate::revlog::{Revlog, RevlogEntry, RevlogError};
 use crate::utils::hg_path::HgPath;
-use crate::vfs::Vfs;
+use crate::vfs::VfsImpl;
 use crate::{Graph, GraphError, RevlogOpenOptions, UncheckedRevision};
 
 /// A specialized `Revlog` to work with changelog data format.
@@ -25,7 +25,7 @@
 impl Changelog {
     /// Open the `changelog` of a repository given by its root.
     pub fn open(
-        store_vfs: &Vfs,
+        store_vfs: &VfsImpl,
         options: RevlogOpenOptions,
     ) -> Result<Self, HgError> {
         let revlog = Revlog::open(store_vfs, "00changelog.i", None, options)?;
@@ -500,7 +500,7 @@
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::vfs::Vfs;
+    use crate::vfs::VfsImpl;
     use crate::{
         RevlogDataConfig, RevlogDeltaConfig, RevlogFeatureConfig,
         NULL_REVISION,
@@ -563,7 +563,9 @@
     fn test_data_from_rev_null() -> Result<(), RevlogError> {
         // an empty revlog will be enough for this case
         let temp = tempfile::tempdir().unwrap();
-        let vfs = Vfs { base: temp.path() };
+        let vfs = VfsImpl {
+            base: temp.path().to_owned(),
+        };
         std::fs::write(temp.path().join("foo.i"), b"").unwrap();
         std::fs::write(temp.path().join("foo.d"), b"").unwrap();
         let revlog = Revlog::open(