diff rust/hg-core/src/repo.rs @ 52297:7be39c5110c9

hg-core: add a complete VFS This will be used from Python in a later change. More changes are needed in hg-core and rhg to properly clean up the APIs of the old VFS implementation but it can be done when the dust settles and we start adding more functionality to the pure Rust VFS.
author Rapha?l Gom?s <rgomes@octobus.net>
date Mon, 29 Jul 2024 20:47:43 +0200
parents 039b7caeb4d9
children bd8081e9fd62
line wrap: on
line diff
--- a/rust/hg-core/src/repo.rs	Mon Jul 29 20:28:42 2024 +0200
+++ b/rust/hg-core/src/repo.rs	Mon Jul 29 20:47:43 2024 +0200
@@ -18,7 +18,7 @@
 use crate::utils::files::get_path_from_bytes;
 use crate::utils::hg_path::HgPath;
 use crate::utils::SliceExt;
-use crate::vfs::{is_dir, is_file, VfsImpl};
+use crate::vfs::{is_dir, is_file, Vfs, VfsImpl};
 use crate::DirstateError;
 use crate::{
     exit_codes, requirements, NodePrefix, RevlogType, UncheckedRevision,
@@ -147,9 +147,7 @@
         let mut repo_config_files =
             vec![dot_hg.join("hgrc"), dot_hg.join("hgrc-not-shared")];
 
-        let hg_vfs = VfsImpl {
-            base: dot_hg.to_owned(),
-        };
+        let hg_vfs = VfsImpl::new(dot_hg.to_owned(), false);
         let mut reqs = requirements::load_if_exists(&hg_vfs)?;
         let relative =
             reqs.contains(requirements::RELATIVE_SHARED_REQUIREMENT);
@@ -191,9 +189,10 @@
 
             store_path = shared_path.join("store");
 
-            let source_is_share_safe = requirements::load(VfsImpl {
-                base: shared_path.to_owned(),
-            })?
+            let source_is_share_safe = requirements::load(VfsImpl::new(
+                shared_path.to_owned(),
+                true,
+            ))?
             .contains(requirements::SHARESAFE_REQUIREMENT);
 
             if share_safe != source_is_share_safe {
@@ -205,9 +204,10 @@
             }
         }
         if share_safe {
-            reqs.extend(requirements::load(VfsImpl {
-                base: store_path.to_owned(),
-            })?);
+            reqs.extend(requirements::load(VfsImpl::new(
+                store_path.to_owned(),
+                true,
+            ))?);
         }
 
         let repo_config = if std::env::var_os("HGRCSKIPREPO").is_none() {
@@ -248,23 +248,17 @@
     /// For accessing repository files (in `.hg`), except for the store
     /// (`.hg/store`).
     pub fn hg_vfs(&self) -> VfsImpl {
-        VfsImpl {
-            base: self.dot_hg.to_owned(),
-        }
+        VfsImpl::new(self.dot_hg.to_owned(), false)
     }
 
     /// For accessing repository store files (in `.hg/store`)
     pub fn store_vfs(&self) -> VfsImpl {
-        VfsImpl {
-            base: self.store.to_owned(),
-        }
+        VfsImpl::new(self.store.to_owned(), false)
     }
 
     /// For accessing the working copy
     pub fn working_directory_vfs(&self) -> VfsImpl {
-        VfsImpl {
-            base: self.working_directory.to_owned(),
-        }
+        VfsImpl::new(self.working_directory.to_owned(), false)
     }
 
     pub fn try_with_wlock_no_wait<R>(
@@ -795,7 +789,7 @@
         if let Some(uuid) = old_uuid_to_remove {
             // Remove the old data file after the new docket pointing to the
             // new data file was written.
-            vfs.remove_file(format!("dirstate.{}", uuid))?;
+            vfs.unlink(Path::new(&format!("dirstate.{}", uuid)))?;
         }
         Ok(())
     }