rust-nodemap-docket: make unaware of `Repo`
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 31 Mar 2022 22:54:33 -0700
changeset 49086 704e993e8ee9
parent 49085 07d8d144c222
child 49087 bfc117647c71
rust-nodemap-docket: make unaware of `Repo` Differential Revision: https://phab.mercurial-scm.org/D12545
rust/hg-core/src/revlog/nodemap_docket.rs
rust/hg-core/src/revlog/revlog.rs
--- a/rust/hg-core/src/revlog/nodemap_docket.rs	Thu Mar 31 22:59:19 2022 -0700
+++ b/rust/hg-core/src/revlog/nodemap_docket.rs	Thu Mar 31 22:54:33 2022 -0700
@@ -3,8 +3,8 @@
 use memmap2::Mmap;
 use std::path::{Path, PathBuf};
 
-use crate::repo::Repo;
 use crate::utils::strip_suffix;
+use crate::vfs::Vfs;
 
 const ONDISK_VERSION: u8 = 1;
 
@@ -34,12 +34,12 @@
     /// * The docket file points to a missing (likely deleted) data file (this
     ///   can happen in a rare race condition).
     pub fn read_from_file(
-        repo: &Repo,
+        store_vfs: &Vfs,
         index_path: &Path,
     ) -> Result<Option<(Self, Mmap)>, HgError> {
         let docket_path = index_path.with_extension("n");
         let docket_bytes = if let Some(bytes) =
-            repo.store_vfs().read(&docket_path).io_not_found_as_none()?
+            store_vfs.read(&docket_path).io_not_found_as_none()?
         {
             bytes
         } else {
@@ -75,10 +75,8 @@
         let data_path = rawdata_path(&docket_path, uid);
         // TODO: use `vfs.read()` here when the `persistent-nodemap.mmap`
         // config is false?
-        if let Some(mmap) = repo
-            .store_vfs()
-            .mmap_open(&data_path)
-            .io_not_found_as_none()?
+        if let Some(mmap) =
+            store_vfs.mmap_open(&data_path).io_not_found_as_none()?
         {
             if mmap.len() >= data_length {
                 Ok(Some((docket, mmap)))
--- a/rust/hg-core/src/revlog/revlog.rs	Thu Mar 31 22:59:19 2022 -0700
+++ b/rust/hg-core/src/revlog/revlog.rs	Thu Mar 31 22:54:33 2022 -0700
@@ -118,7 +118,7 @@
             // If .hg/requires does not opt it, don’t try to open a nodemap
             None
         } else {
-            NodeMapDocket::read_from_file(repo, index_path)?.map(
+            NodeMapDocket::read_from_file(&repo.store_vfs(), index_path)?.map(
                 |(docket, data)| {
                     nodemap::NodeTree::load_bytes(
                         Box::new(data),