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 @@ -6,6 +6,7 @@ // GNU General Public License version 2 or any later version. use crate::repo::Repo; +use crate::requirements; use crate::revlog::revlog::{Revlog, RevlogError}; /// Kind of data to debug @@ -25,7 +26,10 @@ DebugDataKind::Changelog => "00changelog.i", DebugDataKind::Manifest => "00manifest.i", }; - let revlog = Revlog::open(repo, index_file, None)?; + let use_nodemap = repo + .requirements() + .contains(requirements::NODEMAP_REQUIREMENT); + let revlog = Revlog::open(repo, index_file, None, use_nodemap)?; let rev = crate::revset::resolve_rev_number_or_hex_prefix(revset, &revlog)?; let data = revlog.get_rev_data(rev)?; 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 @@ -1,5 +1,6 @@ use crate::errors::HgError; use crate::repo::Repo; +use crate::requirements; use crate::revlog::revlog::{Revlog, RevlogError}; use crate::revlog::Revision; use crate::revlog::{Node, NodePrefix}; @@ -17,7 +18,10 @@ impl Changelog { /// Open the `changelog` of a repository given by its root. pub fn open(repo: &Repo) -> Result { - let revlog = Revlog::open(repo, "00changelog.i", None)?; + let use_nodemap = repo + .requirements() + .contains(requirements::NODEMAP_REQUIREMENT); + let revlog = Revlog::open(repo, "00changelog.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 @@ -1,5 +1,6 @@ use crate::errors::HgError; use crate::repo::Repo; +use crate::requirements; use crate::revlog::path_encode::path_encode; use crate::revlog::revlog::RevlogEntry; use crate::revlog::revlog::{Revlog, RevlogError}; @@ -20,7 +21,11 @@ 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))?; + let use_nodemap = repo + .requirements() + .contains(requirements::NODEMAP_REQUIREMENT); + let revlog = + Revlog::open(repo, index_path, Some(&data_path), use_nodemap)?; Ok(Self { revlog }) } 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,5 +1,6 @@ use crate::errors::HgError; use crate::repo::Repo; +use crate::requirements; use crate::revlog::revlog::{Revlog, RevlogError}; use crate::revlog::Revision; use crate::revlog::{Node, NodePrefix}; @@ -15,7 +16,10 @@ impl Manifestlog { /// Open the `manifest` of a repository given by its root. pub fn open(repo: &Repo) -> Result { - let revlog = Revlog::open(repo, "00manifest.i", None)?; + let use_nodemap = repo + .requirements() + .contains(requirements::NODEMAP_REQUIREMENT); + let revlog = Revlog::open(repo, "00manifest.i", None, use_nodemap)?; Ok(Self { revlog }) } 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::{requirements, Node, NULL_REVISION}; +use crate::{Node, NULL_REVISION}; const REVISION_FLAG_CENSORED: u16 = 1 << 15; const REVISION_FLAG_ELLIPSIS: u16 = 1 << 14; @@ -84,6 +84,7 @@ repo: &Repo, index_path: impl AsRef, data_path: Option<&Path>, + use_nodemap: bool, ) -> Result { let index_path = index_path.as_ref(); let index = { @@ -111,11 +112,7 @@ 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 + } else if !use_nodemap { None } else { NodeMapDocket::read_from_file(&repo.store_vfs(), index_path)?.map(