changeset 49089:399439c12223

rust-revlog: make unaware of `Repo` Differential Revision: https://phab.mercurial-scm.org/D12547
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 12 Apr 2022 21:25:56 -0700
parents b5e226015a14
children a5ef50becea8
files rust/hg-core/src/operations/debugdata.rs rust/hg-core/src/revlog/changelog.rs rust/hg-core/src/revlog/filelog.rs rust/hg-core/src/revlog/manifest.rs rust/hg-core/src/revlog/revlog.rs
diffstat 5 files changed, 25 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/operations/debugdata.rs	Thu Apr 14 09:09:45 2022 -0700
+++ b/rust/hg-core/src/operations/debugdata.rs	Tue Apr 12 21:25:56 2022 -0700
@@ -29,7 +29,8 @@
     let use_nodemap = repo
         .requirements()
         .contains(requirements::NODEMAP_REQUIREMENT);
-    let revlog = Revlog::open(repo, index_file, None, use_nodemap)?;
+    let revlog =
+        Revlog::open(&repo.store_vfs(), index_file, None, use_nodemap)?;
     let rev =
         crate::revset::resolve_rev_number_or_hex_prefix(revset, &revlog)?;
     let data = revlog.get_rev_data(rev)?;
--- a/rust/hg-core/src/revlog/changelog.rs	Thu Apr 14 09:09:45 2022 -0700
+++ b/rust/hg-core/src/revlog/changelog.rs	Tue Apr 12 21:25:56 2022 -0700
@@ -21,7 +21,12 @@
         let use_nodemap = repo
             .requirements()
             .contains(requirements::NODEMAP_REQUIREMENT);
-        let revlog = Revlog::open(repo, "00changelog.i", None, use_nodemap)?;
+        let revlog = Revlog::open(
+            &repo.store_vfs(),
+            "00changelog.i",
+            None,
+            use_nodemap,
+        )?;
         Ok(Self { revlog })
     }
 
--- a/rust/hg-core/src/revlog/filelog.rs	Thu Apr 14 09:09:45 2022 -0700
+++ b/rust/hg-core/src/revlog/filelog.rs	Tue Apr 12 21:25:56 2022 -0700
@@ -20,7 +20,12 @@
     pub fn open(repo: &Repo, file_path: &HgPath) -> Result<Self, HgError> {
         let index_path = store_path(file_path, b".i");
         let data_path = store_path(file_path, b".d");
-        let revlog = Revlog::open(repo, index_path, Some(&data_path), false)?;
+        let revlog = Revlog::open(
+            &repo.store_vfs(),
+            index_path,
+            Some(&data_path),
+            false,
+        )?;
         Ok(Self { revlog })
     }
 
--- a/rust/hg-core/src/revlog/manifest.rs	Thu Apr 14 09:09:45 2022 -0700
+++ b/rust/hg-core/src/revlog/manifest.rs	Tue Apr 12 21:25:56 2022 -0700
@@ -19,7 +19,12 @@
         let use_nodemap = repo
             .requirements()
             .contains(requirements::NODEMAP_REQUIREMENT);
-        let revlog = Revlog::open(repo, "00manifest.i", None, use_nodemap)?;
+        let revlog = Revlog::open(
+            &repo.store_vfs(),
+            "00manifest.i",
+            None,
+            use_nodemap,
+        )?;
         Ok(Self { revlog })
     }
 
--- a/rust/hg-core/src/revlog/revlog.rs	Thu Apr 14 09:09:45 2022 -0700
+++ b/rust/hg-core/src/revlog/revlog.rs	Tue Apr 12 21:25:56 2022 -0700
@@ -16,8 +16,8 @@
 use super::nodemap_docket::NodeMapDocket;
 use super::patch;
 use crate::errors::HgError;
-use crate::repo::Repo;
 use crate::revlog::Revision;
+use crate::vfs::Vfs;
 use crate::{Node, NULL_REVISION};
 
 const REVISION_FLAG_CENSORED: u16 = 1 << 15;
@@ -81,14 +81,14 @@
     /// interleaved.
     #[timed]
     pub fn open(
-        repo: &Repo,
+        store_vfs: &Vfs,
         index_path: impl AsRef<Path>,
         data_path: Option<&Path>,
         use_nodemap: bool,
     ) -> Result<Self, HgError> {
         let index_path = index_path.as_ref();
         let index = {
-            match repo.store_vfs().mmap_open_opt(&index_path)? {
+            match store_vfs.mmap_open_opt(&index_path)? {
                 None => Index::new(Box::new(vec![])),
                 Some(index_mmap) => {
                     let index = Index::new(Box::new(index_mmap))?;
@@ -106,7 +106,7 @@
                 None
             } else {
                 let data_path = data_path.unwrap_or(&default_data_path);
-                let data_mmap = repo.store_vfs().mmap_open(data_path)?;
+                let data_mmap = store_vfs.mmap_open(data_path)?;
                 Some(Box::new(data_mmap))
             };
 
@@ -115,7 +115,7 @@
         } else if !use_nodemap {
             None
         } else {
-            NodeMapDocket::read_from_file(&repo.store_vfs(), index_path)?.map(
+            NodeMapDocket::read_from_file(store_vfs, index_path)?.map(
                 |(docket, data)| {
                     nodemap::NodeTree::load_bytes(
                         Box::new(data),