Show More
@@ -8,8 +8,6 b'' | |||
|
8 | 8 | use std::path::PathBuf; |
|
9 | 9 | |
|
10 | 10 | use crate::repo::Repo; |
|
11 | use crate::revlog::changelog::Changelog; | |
|
12 | use crate::revlog::manifest::Manifestlog; | |
|
13 | 11 | use crate::revlog::path_encode::path_encode; |
|
14 | 12 | use crate::revlog::revlog::Revlog; |
|
15 | 13 | use crate::revlog::revlog::RevlogError; |
@@ -42,8 +40,8 b" pub fn cat<'a>(" | |||
|
42 | 40 | files: &'a [HgPathBuf], |
|
43 | 41 | ) -> Result<CatOutput, RevlogError> { |
|
44 | 42 | let rev = crate::revset::resolve_single(revset, repo)?; |
|
45 |
let changelog = |
|
|
46 |
let manifest = |
|
|
43 | let changelog = repo.changelog()?; | |
|
44 | let manifest = repo.manifestlog()?; | |
|
47 | 45 | let changelog_entry = changelog.get_rev(rev)?; |
|
48 | 46 | let node = *changelog |
|
49 | 47 | .node_from_rev(rev) |
@@ -9,8 +9,7 b' use crate::dirstate::parsers::parse_dirs' | |||
|
9 | 9 | use crate::dirstate_tree::on_disk::{for_each_tracked_path, read_docket}; |
|
10 | 10 | use crate::errors::HgError; |
|
11 | 11 | use crate::repo::Repo; |
|
12 |
use crate::revlog:: |
|
|
13 | use crate::revlog::manifest::{Manifest, Manifestlog}; | |
|
12 | use crate::revlog::manifest::Manifest; | |
|
14 | 13 | use crate::revlog::node::Node; |
|
15 | 14 | use crate::revlog::revlog::RevlogError; |
|
16 | 15 | use crate::utils::hg_path::HgPath; |
@@ -72,8 +71,8 b' pub fn list_rev_tracked_files(' | |||
|
72 | 71 | revset: &str, |
|
73 | 72 | ) -> Result<FilesForRev, RevlogError> { |
|
74 | 73 | let rev = crate::revset::resolve_single(revset, repo)?; |
|
75 |
let changelog = |
|
|
76 |
let manifest = |
|
|
74 | let changelog = repo.changelog()?; | |
|
75 | let manifest = repo.manifestlog()?; | |
|
77 | 76 | let changelog_entry = changelog.get_rev(rev)?; |
|
78 | 77 | let manifest_node = |
|
79 | 78 | Node::from_hex_for_repo(&changelog_entry.manifest_node()?)?; |
@@ -1,3 +1,4 b'' | |||
|
1 | use crate::changelog::Changelog; | |
|
1 | 2 | use crate::config::{Config, ConfigError, ConfigParseError}; |
|
2 | 3 | use crate::dirstate::DirstateParents; |
|
3 | 4 | use crate::dirstate_tree::dirstate_map::DirstateMap; |
@@ -5,7 +6,9 b' use crate::dirstate_tree::owning::Owning' | |||
|
5 | 6 | use crate::errors::HgError; |
|
6 | 7 | use crate::errors::HgResultExt; |
|
7 | 8 | use crate::exit_codes; |
|
9 | use crate::manifest::Manifestlog; | |
|
8 | 10 | use crate::requirements; |
|
11 | use crate::revlog::revlog::RevlogError; | |
|
9 | 12 | use crate::utils::files::get_path_from_bytes; |
|
10 | 13 | use crate::utils::SliceExt; |
|
11 | 14 | use crate::vfs::{is_dir, is_file, Vfs}; |
@@ -24,6 +27,8 b' pub struct Repo {' | |||
|
24 | 27 | // None means not known/initialized yet |
|
25 | 28 | dirstate_parents: Cell<Option<DirstateParents>>, |
|
26 | 29 | dirstate_map: LazyCell<OwningDirstateMap, DirstateError>, |
|
30 | changelog: LazyCell<Changelog, RevlogError>, | |
|
31 | manifestlog: LazyCell<Manifestlog, RevlogError>, | |
|
27 | 32 | } |
|
28 | 33 | |
|
29 | 34 | #[derive(Debug, derive_more::From)] |
@@ -197,6 +202,8 b' impl Repo {' | |||
|
197 | 202 | config: repo_config, |
|
198 | 203 | dirstate_parents: Cell::new(None), |
|
199 | 204 | dirstate_map: LazyCell::new(Self::new_dirstate_map), |
|
205 | changelog: LazyCell::new(Changelog::open), | |
|
206 | manifestlog: LazyCell::new(Manifestlog::open), | |
|
200 | 207 | }; |
|
201 | 208 | |
|
202 | 209 | requirements::check(&repo)?; |
@@ -310,6 +317,22 b' impl Repo {' | |||
|
310 | 317 | ) -> Result<RefMut<OwningDirstateMap>, DirstateError> { |
|
311 | 318 | self.dirstate_map.get_mut_or_init(self) |
|
312 | 319 | } |
|
320 | ||
|
321 | pub fn changelog(&self) -> Result<Ref<Changelog>, RevlogError> { | |
|
322 | self.changelog.get_or_init(self) | |
|
323 | } | |
|
324 | ||
|
325 | pub fn changelog_mut(&self) -> Result<RefMut<Changelog>, RevlogError> { | |
|
326 | self.changelog.get_mut_or_init(self) | |
|
327 | } | |
|
328 | ||
|
329 | pub fn manifestlog(&self) -> Result<Ref<Manifestlog>, RevlogError> { | |
|
330 | self.manifestlog.get_or_init(self) | |
|
331 | } | |
|
332 | ||
|
333 | pub fn manifestlog_mut(&self) -> Result<RefMut<Manifestlog>, RevlogError> { | |
|
334 | self.manifestlog.get_mut_or_init(self) | |
|
335 | } | |
|
313 | 336 | } |
|
314 | 337 | |
|
315 | 338 | /// Lazily-initialized component of `Repo` with interior mutability |
@@ -4,7 +4,6 b'' | |||
|
4 | 4 | |
|
5 | 5 | use crate::errors::HgError; |
|
6 | 6 | use crate::repo::Repo; |
|
7 | use crate::revlog::changelog::Changelog; | |
|
8 | 7 | use crate::revlog::revlog::{Revlog, RevlogError}; |
|
9 | 8 | use crate::revlog::NodePrefix; |
|
10 | 9 | use crate::revlog::{Revision, NULL_REVISION, WORKING_DIRECTORY_HEX}; |
@@ -17,7 +16,7 b' pub fn resolve_single(' | |||
|
17 | 16 | input: &str, |
|
18 | 17 | repo: &Repo, |
|
19 | 18 | ) -> Result<Revision, RevlogError> { |
|
20 |
let changelog = |
|
|
19 | let changelog = repo.changelog()?; | |
|
21 | 20 | |
|
22 | 21 | match resolve_rev_number_or_hex_prefix(input, &changelog.revlog) { |
|
23 | 22 | Err(RevlogError::InvalidRevision) => {} // Try other syntax |
General Comments 0
You need to be logged in to leave comments.
Login now