diff --git a/rust/hg-core/src/repo.rs b/rust/hg-core/src/repo.rs --- a/rust/hg-core/src/repo.rs +++ b/rust/hg-core/src/repo.rs @@ -29,8 +29,8 @@ // None means not known/initialized yet dirstate_parents: Cell>, dirstate_map: LazyCell, - changelog: LazyCell, - manifestlog: LazyCell, + changelog: LazyCell, + manifestlog: LazyCell, } #[derive(Debug, derive_more::From)] @@ -320,19 +320,19 @@ self.dirstate_map.get_mut_or_init(self) } - pub fn changelog(&self) -> Result, RevlogError> { + pub fn changelog(&self) -> Result, HgError> { self.changelog.get_or_init(self) } - pub fn changelog_mut(&self) -> Result, RevlogError> { + pub fn changelog_mut(&self) -> Result, HgError> { self.changelog.get_mut_or_init(self) } - pub fn manifestlog(&self) -> Result, RevlogError> { + pub fn manifestlog(&self) -> Result, HgError> { self.manifestlog.get_or_init(self) } - pub fn manifestlog_mut(&self) -> Result, RevlogError> { + pub fn manifestlog_mut(&self) -> Result, HgError> { self.manifestlog.get_mut_or_init(self) } @@ -349,7 +349,7 @@ manifest.get_node(manifest_node.into()) } - pub fn filelog(&self, path: &HgPath) -> Result { + pub fn filelog(&self, path: &HgPath) -> Result { Filelog::open(self, path) } } 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 @@ -12,7 +12,7 @@ impl Changelog { /// Open the `changelog` of a repository given by its root. - pub fn open(repo: &Repo) -> Result { + pub fn open(repo: &Repo) -> Result { let revlog = Revlog::open(repo, "00changelog.i", None)?; 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 @@ -17,7 +17,7 @@ } impl Filelog { - pub fn open(repo: &Repo, file_path: &HgPath) -> Result { + pub fn open(repo: &Repo, file_path: &HgPath) -> Result { 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))?; diff --git a/rust/hg-core/src/revlog/index.rs b/rust/hg-core/src/revlog/index.rs --- a/rust/hg-core/src/revlog/index.rs +++ b/rust/hg-core/src/revlog/index.rs @@ -5,7 +5,6 @@ use crate::errors::HgError; use crate::revlog::node::Node; -use crate::revlog::revlog::RevlogError; use crate::revlog::{Revision, NULL_REVISION}; pub const INDEX_ENTRY_SIZE: usize = 64; @@ -23,7 +22,7 @@ /// Calculate the start of each entry when is_inline is true. pub fn new( bytes: Box + Send>, - ) -> Result { + ) -> Result { if is_inline(&bytes) { let mut offset: usize = 0; let mut offsets = Vec::new(); 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 @@ -1,3 +1,4 @@ +use crate::errors::HgError; use crate::repo::Repo; use crate::revlog::revlog::{Revlog, RevlogError}; use crate::revlog::NodePrefix; @@ -12,7 +13,7 @@ impl Manifestlog { /// Open the `manifest` of a repository given by its root. - pub fn open(repo: &Repo) -> Result { + pub fn open(repo: &Repo) -> Result { let revlog = Revlog::open(repo, "00manifest.i", None)?; Ok(Self { revlog }) } diff --git a/rust/hg-core/src/revlog/nodemap_docket.rs b/rust/hg-core/src/revlog/nodemap_docket.rs --- a/rust/hg-core/src/revlog/nodemap_docket.rs +++ b/rust/hg-core/src/revlog/nodemap_docket.rs @@ -4,7 +4,6 @@ use memmap2::Mmap; use std::path::{Path, PathBuf}; -use super::revlog::RevlogError; use crate::repo::Repo; use crate::utils::strip_suffix; @@ -38,7 +37,7 @@ pub fn read_from_file( repo: &Repo, index_path: &Path, - ) -> Result, RevlogError> { + ) -> Result, HgError> { if !repo .requirements() .contains(requirements::NODEMAP_REQUIREMENT) @@ -65,10 +64,9 @@ }; /// Treat any error as a parse error - fn parse(result: Result) -> Result { - result.map_err(|_| { - HgError::corrupted("nodemap docket parse error").into() - }) + fn parse(result: Result) -> Result { + result + .map_err(|_| HgError::corrupted("nodemap docket parse error")) } let (header, rest) = parse(DocketHeader::from_bytes(input))?; @@ -94,7 +92,7 @@ if mmap.len() >= data_length { Ok(Some((docket, mmap))) } else { - Err(HgError::corrupted("persistent nodemap too short").into()) + Err(HgError::corrupted("persistent nodemap too short")) } } else { // Even if .hg/requires opted in, some revlogs are deemed small 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 @@ -68,14 +68,14 @@ repo: &Repo, index_path: impl AsRef, data_path: Option<&Path>, - ) -> Result { + ) -> Result { let index_path = index_path.as_ref(); let index_mmap = repo.store_vfs().mmap_open(&index_path)?; let version = get_version(&index_mmap); if version != 1 { // A proper new version should have had a repo/store requirement. - return Err(RevlogError::corrupted()); + return Err(HgError::corrupted("corrupted revlog")); } let index = Index::new(Box::new(index_mmap))?;