changeset 46630:842f2372ced6

rhg: Don’t attempt to read persistent nodemap without .hg/requires opt-in Differential Revision: https://phab.mercurial-scm.org/D10077
author Simon Sapin <simon.sapin@octobus.net>
date Thu, 25 Feb 2021 21:29:12 +0100
parents 90481550467c
children 230f73019e49
files rust/hg-core/src/revlog/nodemap_docket.rs
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/nodemap_docket.rs	Thu Feb 04 17:34:20 2021 -0800
+++ b/rust/hg-core/src/revlog/nodemap_docket.rs	Thu Feb 25 21:29:12 2021 +0100
@@ -1,4 +1,5 @@
 use crate::errors::{HgError, HgResultExt};
+use crate::requirements;
 use bytes_cast::{unaligned, BytesCast};
 use memmap::Mmap;
 use std::path::{Path, PathBuf};
@@ -38,6 +39,14 @@
         repo: &Repo,
         index_path: &Path,
     ) -> Result<Option<(Self, Mmap)>, RevlogError> {
+        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()?
@@ -88,6 +97,8 @@
                 Err(HgError::corrupted("persistent nodemap too short").into())
             }
         } else {
+            // Even if .hg/requires opted in, some revlogs are deemed small
+            // enough to not need a persistent nodemap.
             Ok(None)
         }
     }