martinvonz created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches.
REVISION SUMMARY I think it's cleaner if `NodeMapDocket` doesn't know about the `Repo` type. That makes it more easily reusable and testable. This patch moves out one of the uses of `Repo` out of it. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12544 AFFECTED FILES rust/hg-core/src/revlog/nodemap_docket.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 @@ -18,7 +18,7 @@ use crate::errors::HgError; use crate::repo::Repo; use crate::revlog::Revision; -use crate::{Node, NULL_REVISION}; +use crate::{requirements, Node, NULL_REVISION}; const REVISION_FLAG_CENSORED: u16 = 1 << 15; const REVISION_FLAG_ELLIPSIS: u16 = 1 << 14; @@ -111,6 +111,12 @@ let nodemap = if index.is_inline() { None + } else if !repo + .requirements() + .contains(requirements::NODEMAP_REQUIREMENT) + { + // If .hg/requires does not opt it, don’t try to open a nodemap + None } else { NodeMapDocket::read_from_file(repo, index_path)?.map( |(docket, data)| { 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 @@ -1,5 +1,4 @@ use crate::errors::{HgError, HgResultExt}; -use crate::requirements; use bytes_cast::{unaligned, BytesCast}; use memmap2::Mmap; use std::path::{Path, PathBuf}; @@ -38,14 +37,6 @@ repo: &Repo, index_path: &Path, ) -> Result<Option<(Self, Mmap)>, HgError> { - if !repo - .requirements() - .contains(requirements::NODEMAP_REQUIREMENT) - { - // If .hg/requires does not opt it, don’t try to open a nodemap - return Ok(None); - } - let docket_path = index_path.with_extension("n"); let docket_bytes = if let Some(bytes) = repo.store_vfs().read(&docket_path).io_not_found_as_none()? To: martinvonz, #hg-reviewers Cc: mercurial-patches, mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel