Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/repo.rs @ 47961:4d2a5ca060e3
rust: Add a Filelog struct that wraps Revlog
Some filelog-specific logic is moved from code `rhg cat` into this struct
where it can better be reused.
Additionally, a missing end delimiter for metadata causes an error
to be returned instead of being silently ignored.
Differential Revision: https://phab.mercurial-scm.org/D11408
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 13 Sep 2021 15:42:39 +0200 |
parents | cfb6e6699b25 |
children | 001d747c2baf |
comparison
equal
deleted
inserted
replaced
47960:cfb6e6699b25 | 47961:4d2a5ca060e3 |
---|---|
5 use crate::dirstate_tree::owning::OwningDirstateMap; | 5 use crate::dirstate_tree::owning::OwningDirstateMap; |
6 use crate::errors::HgError; | 6 use crate::errors::HgError; |
7 use crate::errors::HgResultExt; | 7 use crate::errors::HgResultExt; |
8 use crate::manifest::{Manifest, Manifestlog}; | 8 use crate::manifest::{Manifest, Manifestlog}; |
9 use crate::requirements; | 9 use crate::requirements; |
10 use crate::revlog::filelog::Filelog; | |
10 use crate::revlog::revlog::RevlogError; | 11 use crate::revlog::revlog::RevlogError; |
11 use crate::utils::files::get_path_from_bytes; | 12 use crate::utils::files::get_path_from_bytes; |
13 use crate::utils::hg_path::HgPath; | |
12 use crate::utils::SliceExt; | 14 use crate::utils::SliceExt; |
13 use crate::vfs::{is_dir, is_file, Vfs}; | 15 use crate::vfs::{is_dir, is_file, Vfs}; |
14 use crate::{exit_codes, Node}; | 16 use crate::{exit_codes, Node}; |
15 use crate::{DirstateError, Revision}; | 17 use crate::{DirstateError, Revision}; |
16 use std::cell::{Cell, Ref, RefCell, RefMut}; | 18 use std::cell::{Cell, Ref, RefCell, RefMut}; |
344 let changelog_entry = changelog.get_rev(revision)?; | 346 let changelog_entry = changelog.get_rev(revision)?; |
345 let manifest_node = | 347 let manifest_node = |
346 Node::from_hex_for_repo(&changelog_entry.manifest_node()?)?; | 348 Node::from_hex_for_repo(&changelog_entry.manifest_node()?)?; |
347 manifest.get_node(manifest_node.into()) | 349 manifest.get_node(manifest_node.into()) |
348 } | 350 } |
351 | |
352 pub fn filelog(&self, path: &HgPath) -> Result<Filelog, RevlogError> { | |
353 Filelog::open(self, path) | |
354 } | |
349 } | 355 } |
350 | 356 |
351 /// Lazily-initialized component of `Repo` with interior mutability | 357 /// Lazily-initialized component of `Repo` with interior mutability |
352 /// | 358 /// |
353 /// This differs from `OnceCell` in that the value can still be "deinitialized" | 359 /// This differs from `OnceCell` in that the value can still be "deinitialized" |