##// END OF EJS Templates
rust-nodemap-docket: make unaware of `Repo`...
Martin von Zweigbergk -
r49977:704e993e default
parent child Browse files
Show More
@@ -3,8 +3,8 b' use bytes_cast::{unaligned, BytesCast};'
3 use memmap2::Mmap;
3 use memmap2::Mmap;
4 use std::path::{Path, PathBuf};
4 use std::path::{Path, PathBuf};
5
5
6 use crate::repo::Repo;
7 use crate::utils::strip_suffix;
6 use crate::utils::strip_suffix;
7 use crate::vfs::Vfs;
8
8
9 const ONDISK_VERSION: u8 = 1;
9 const ONDISK_VERSION: u8 = 1;
10
10
@@ -34,12 +34,12 b' impl NodeMapDocket {'
34 /// * The docket file points to a missing (likely deleted) data file (this
34 /// * The docket file points to a missing (likely deleted) data file (this
35 /// can happen in a rare race condition).
35 /// can happen in a rare race condition).
36 pub fn read_from_file(
36 pub fn read_from_file(
37 repo: &Repo,
37 store_vfs: &Vfs,
38 index_path: &Path,
38 index_path: &Path,
39 ) -> Result<Option<(Self, Mmap)>, HgError> {
39 ) -> Result<Option<(Self, Mmap)>, HgError> {
40 let docket_path = index_path.with_extension("n");
40 let docket_path = index_path.with_extension("n");
41 let docket_bytes = if let Some(bytes) =
41 let docket_bytes = if let Some(bytes) =
42 repo.store_vfs().read(&docket_path).io_not_found_as_none()?
42 store_vfs.read(&docket_path).io_not_found_as_none()?
43 {
43 {
44 bytes
44 bytes
45 } else {
45 } else {
@@ -75,10 +75,8 b' impl NodeMapDocket {'
75 let data_path = rawdata_path(&docket_path, uid);
75 let data_path = rawdata_path(&docket_path, uid);
76 // TODO: use `vfs.read()` here when the `persistent-nodemap.mmap`
76 // TODO: use `vfs.read()` here when the `persistent-nodemap.mmap`
77 // config is false?
77 // config is false?
78 if let Some(mmap) = repo
78 if let Some(mmap) =
79 .store_vfs()
79 store_vfs.mmap_open(&data_path).io_not_found_as_none()?
80 .mmap_open(&data_path)
81 .io_not_found_as_none()?
82 {
80 {
83 if mmap.len() >= data_length {
81 if mmap.len() >= data_length {
84 Ok(Some((docket, mmap)))
82 Ok(Some((docket, mmap)))
@@ -118,7 +118,7 b' impl Revlog {'
118 // If .hg/requires does not opt it, don’t try to open a nodemap
118 // If .hg/requires does not opt it, don’t try to open a nodemap
119 None
119 None
120 } else {
120 } else {
121 NodeMapDocket::read_from_file(repo, index_path)?.map(
121 NodeMapDocket::read_from_file(&repo.store_vfs(), index_path)?.map(
122 |(docket, data)| {
122 |(docket, data)| {
123 nodemap::NodeTree::load_bytes(
123 nodemap::NodeTree::load_bytes(
124 Box::new(data),
124 Box::new(data),
General Comments 0
You need to be logged in to leave comments. Login now