[Updated] D12547: rust-revlog: make unaware of `Repo`
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Thu Apr 14 16:13:59 UTC 2022
martinvonz updated this revision to Diff 33178.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D12547?vs=33155&id=33178
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D12547/new/
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
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
@@ -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 })
}
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)?;
To: martinvonz, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220414/697cc4c7/attachment-0002.html>
More information about the Mercurial-patches
mailing list