diff rust/hg-core/src/revlog/revlog.rs @ 49142:bfc117647c71

rust-revlog: move check for nodemap requirement to caller It's good for both making `Revlog` testable and reusable to have it not depend on the higher-level `Repo` type. This patch is one step in towards that. Additionally, this change in particular gives the callers more control over when to use a nodemap. Differential Revision: https://phab.mercurial-scm.org/D12546
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 12 Apr 2022 11:40:37 -0700
parents 704e993e8ee9
children 399439c12223
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/revlog.rs	Thu Mar 31 22:54:33 2022 -0700
+++ b/rust/hg-core/src/revlog/revlog.rs	Tue Apr 12 11:40:37 2022 -0700
@@ -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<Path>,
         data_path: Option<&Path>,
+        use_nodemap: bool,
     ) -> Result<Self, HgError> {
         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(