rust/hg-core/src/revlog/nodemap_docket.rs
changeset 49085 07d8d144c222
parent 47963 001d747c2baf
child 49086 704e993e8ee9
equal deleted inserted replaced
49084:ea98850a136e 49085:07d8d144c222
     1 use crate::errors::{HgError, HgResultExt};
     1 use crate::errors::{HgError, HgResultExt};
     2 use crate::requirements;
       
     3 use bytes_cast::{unaligned, BytesCast};
     2 use bytes_cast::{unaligned, BytesCast};
     4 use memmap2::Mmap;
     3 use memmap2::Mmap;
     5 use std::path::{Path, PathBuf};
     4 use std::path::{Path, PathBuf};
     6 
     5 
     7 use crate::repo::Repo;
     6 use crate::repo::Repo;
    36     ///   can happen in a rare race condition).
    35     ///   can happen in a rare race condition).
    37     pub fn read_from_file(
    36     pub fn read_from_file(
    38         repo: &Repo,
    37         repo: &Repo,
    39         index_path: &Path,
    38         index_path: &Path,
    40     ) -> Result<Option<(Self, Mmap)>, HgError> {
    39     ) -> Result<Option<(Self, Mmap)>, HgError> {
    41         if !repo
       
    42             .requirements()
       
    43             .contains(requirements::NODEMAP_REQUIREMENT)
       
    44         {
       
    45             // If .hg/requires does not opt it, don’t try to open a nodemap
       
    46             return Ok(None);
       
    47         }
       
    48 
       
    49         let docket_path = index_path.with_extension("n");
    40         let docket_path = index_path.with_extension("n");
    50         let docket_bytes = if let Some(bytes) =
    41         let docket_bytes = if let Some(bytes) =
    51             repo.store_vfs().read(&docket_path).io_not_found_as_none()?
    42             repo.store_vfs().read(&docket_path).io_not_found_as_none()?
    52         {
    43         {
    53             bytes
    44             bytes