Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/repo.rs @ 47960:cfb6e6699b25
rust: Add Repo::manifest(revision)
This deduplicates some common code.
Differential Revision: https://phab.mercurial-scm.org/D11407
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 13 Sep 2021 13:45:10 +0200 |
parents | 21d25e9ee58e |
children | 4d2a5ca060e3 |
comparison
equal
deleted
inserted
replaced
47959:21d25e9ee58e | 47960:cfb6e6699b25 |
---|---|
3 use crate::dirstate::DirstateParents; | 3 use crate::dirstate::DirstateParents; |
4 use crate::dirstate_tree::dirstate_map::DirstateMap; | 4 use crate::dirstate_tree::dirstate_map::DirstateMap; |
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::exit_codes; | 8 use crate::manifest::{Manifest, Manifestlog}; |
9 use crate::manifest::Manifestlog; | |
10 use crate::requirements; | 9 use crate::requirements; |
11 use crate::revlog::revlog::RevlogError; | 10 use crate::revlog::revlog::RevlogError; |
12 use crate::utils::files::get_path_from_bytes; | 11 use crate::utils::files::get_path_from_bytes; |
13 use crate::utils::SliceExt; | 12 use crate::utils::SliceExt; |
14 use crate::vfs::{is_dir, is_file, Vfs}; | 13 use crate::vfs::{is_dir, is_file, Vfs}; |
15 use crate::DirstateError; | 14 use crate::{exit_codes, Node}; |
15 use crate::{DirstateError, Revision}; | |
16 use std::cell::{Cell, Ref, RefCell, RefMut}; | 16 use std::cell::{Cell, Ref, RefCell, RefMut}; |
17 use std::collections::HashSet; | 17 use std::collections::HashSet; |
18 use std::path::{Path, PathBuf}; | 18 use std::path::{Path, PathBuf}; |
19 | 19 |
20 /// A repository on disk | 20 /// A repository on disk |
331 } | 331 } |
332 | 332 |
333 pub fn manifestlog_mut(&self) -> Result<RefMut<Manifestlog>, RevlogError> { | 333 pub fn manifestlog_mut(&self) -> Result<RefMut<Manifestlog>, RevlogError> { |
334 self.manifestlog.get_mut_or_init(self) | 334 self.manifestlog.get_mut_or_init(self) |
335 } | 335 } |
336 | |
337 /// Returns the manifest of the given revision | |
338 pub fn manifest( | |
339 &self, | |
340 revision: Revision, | |
341 ) -> Result<Manifest, RevlogError> { | |
342 let changelog = self.changelog()?; | |
343 let manifest = self.manifestlog()?; | |
344 let changelog_entry = changelog.get_rev(revision)?; | |
345 let manifest_node = | |
346 Node::from_hex_for_repo(&changelog_entry.manifest_node()?)?; | |
347 manifest.get_node(manifest_node.into()) | |
348 } | |
336 } | 349 } |
337 | 350 |
338 /// Lazily-initialized component of `Repo` with interior mutability | 351 /// Lazily-initialized component of `Repo` with interior mutability |
339 /// | 352 /// |
340 /// This differs from `OnceCell` in that the value can still be "deinitialized" | 353 /// This differs from `OnceCell` in that the value can still be "deinitialized" |