Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/repo.rs @ 49090:a5ef50becea8
rust-revlog: make `Changelog` and `ManifestLog` unaware of `Repo`
As with other recent patches, this makes the types easier to test and
reuse.
Differential Revision: https://phab.mercurial-scm.org/D12561
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 15 Apr 2022 09:37:13 -0700 |
parents | 12adf8c695ed |
children | 9b5334c1e499 |
comparison
equal
deleted
inserted
replaced
49089:399439c12223 | 49090:a5ef50becea8 |
---|---|
185 dirstate_parents: LazyCell::new(Self::read_dirstate_parents), | 185 dirstate_parents: LazyCell::new(Self::read_dirstate_parents), |
186 dirstate_data_file_uuid: LazyCell::new( | 186 dirstate_data_file_uuid: LazyCell::new( |
187 Self::read_dirstate_data_file_uuid, | 187 Self::read_dirstate_data_file_uuid, |
188 ), | 188 ), |
189 dirstate_map: LazyCell::new(Self::new_dirstate_map), | 189 dirstate_map: LazyCell::new(Self::new_dirstate_map), |
190 changelog: LazyCell::new(Changelog::open), | 190 changelog: LazyCell::new(Self::new_changelog), |
191 manifestlog: LazyCell::new(Manifestlog::open), | 191 manifestlog: LazyCell::new(Self::new_manifestlog), |
192 }; | 192 }; |
193 | 193 |
194 requirements::check(&repo)?; | 194 requirements::check(&repo)?; |
195 | 195 |
196 Ok(repo) | 196 Ok(repo) |
342 &self, | 342 &self, |
343 ) -> Result<RefMut<OwningDirstateMap>, DirstateError> { | 343 ) -> Result<RefMut<OwningDirstateMap>, DirstateError> { |
344 self.dirstate_map.get_mut_or_init(self) | 344 self.dirstate_map.get_mut_or_init(self) |
345 } | 345 } |
346 | 346 |
347 fn new_changelog(&self) -> Result<Changelog, HgError> { | |
348 let use_nodemap = self | |
349 .requirements | |
350 .contains(requirements::NODEMAP_REQUIREMENT); | |
351 Changelog::open(&self.store_vfs(), use_nodemap) | |
352 } | |
353 | |
347 pub fn changelog(&self) -> Result<Ref<Changelog>, HgError> { | 354 pub fn changelog(&self) -> Result<Ref<Changelog>, HgError> { |
348 self.changelog.get_or_init(self) | 355 self.changelog.get_or_init(self) |
349 } | 356 } |
350 | 357 |
351 pub fn changelog_mut(&self) -> Result<RefMut<Changelog>, HgError> { | 358 pub fn changelog_mut(&self) -> Result<RefMut<Changelog>, HgError> { |
352 self.changelog.get_mut_or_init(self) | 359 self.changelog.get_mut_or_init(self) |
360 } | |
361 | |
362 fn new_manifestlog(&self) -> Result<Manifestlog, HgError> { | |
363 let use_nodemap = self | |
364 .requirements | |
365 .contains(requirements::NODEMAP_REQUIREMENT); | |
366 Manifestlog::open(&self.store_vfs(), use_nodemap) | |
353 } | 367 } |
354 | 368 |
355 pub fn manifestlog(&self) -> Result<Ref<Manifestlog>, HgError> { | 369 pub fn manifestlog(&self) -> Result<Ref<Manifestlog>, HgError> { |
356 self.manifestlog.get_or_init(self) | 370 self.manifestlog.get_or_init(self) |
357 } | 371 } |