Patchwork D12547: rust-revlog: make unaware of `Repo`

login
register
mail settings
Submitter phabricator
Date April 13, 2022, 1:11 p.m.
Message ID <differential-rev-PHID-DREV-k6gc7rymvagmfgnkj2fm-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50895/
State New
Headers show

Comments

phabricator - April 13, 2022, 1:11 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12547

AFFECTED 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

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/hg-core/src/revlog/revlog.rs b/rust/hg-core/src/revlog/revlog.rs
--- a/rust/hg-core/src/revlog/revlog.rs
+++ b/rust/hg-core/src/revlog/revlog.rs
@@ -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),
diff --git a/rust/hg-core/src/revlog/manifest.rs b/rust/hg-core/src/revlog/manifest.rs
--- a/rust/hg-core/src/revlog/manifest.rs
+++ b/rust/hg-core/src/revlog/manifest.rs
@@ -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 })
     }
 
diff --git a/rust/hg-core/src/revlog/filelog.rs b/rust/hg-core/src/revlog/filelog.rs
--- a/rust/hg-core/src/revlog/filelog.rs
+++ b/rust/hg-core/src/revlog/filelog.rs
@@ -24,8 +24,12 @@ 
         let use_nodemap = repo
             .requirements()
             .contains(requirements::NODEMAP_REQUIREMENT);
-        let revlog =
-            Revlog::open(repo, index_path, Some(&data_path), use_nodemap)?;
+        let revlog = Revlog::open(
+            &repo.store_vfs(),
+            index_path,
+            Some(&data_path),
+            use_nodemap,
+        )?;
         Ok(Self { revlog })
     }
 
diff --git a/rust/hg-core/src/revlog/changelog.rs b/rust/hg-core/src/revlog/changelog.rs
--- a/rust/hg-core/src/revlog/changelog.rs
+++ b/rust/hg-core/src/revlog/changelog.rs
@@ -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 })
     }
 
diff --git a/rust/hg-core/src/operations/debugdata.rs b/rust/hg-core/src/operations/debugdata.rs
--- a/rust/hg-core/src/operations/debugdata.rs
+++ b/rust/hg-core/src/operations/debugdata.rs
@@ -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)?;