Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/repo.rs @ 47963:001d747c2baf
rust: Return HgError instead of RevlogError in revlog constructors
This leaves fewer cases for callers to handle, as RevlogError is more general
Differential Revision: https://phab.mercurial-scm.org/D11410
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 13 Sep 2021 18:02:45 +0200 |
parents | 4d2a5ca060e3 |
children | 796206e74b10 |
comparison
equal
deleted
inserted
replaced
47962:8c29af0f6d6e | 47963:001d747c2baf |
---|---|
27 requirements: HashSet<String>, | 27 requirements: HashSet<String>, |
28 config: Config, | 28 config: Config, |
29 // None means not known/initialized yet | 29 // None means not known/initialized yet |
30 dirstate_parents: Cell<Option<DirstateParents>>, | 30 dirstate_parents: Cell<Option<DirstateParents>>, |
31 dirstate_map: LazyCell<OwningDirstateMap, DirstateError>, | 31 dirstate_map: LazyCell<OwningDirstateMap, DirstateError>, |
32 changelog: LazyCell<Changelog, RevlogError>, | 32 changelog: LazyCell<Changelog, HgError>, |
33 manifestlog: LazyCell<Manifestlog, RevlogError>, | 33 manifestlog: LazyCell<Manifestlog, HgError>, |
34 } | 34 } |
35 | 35 |
36 #[derive(Debug, derive_more::From)] | 36 #[derive(Debug, derive_more::From)] |
37 pub enum RepoError { | 37 pub enum RepoError { |
38 NotFound { | 38 NotFound { |
318 &self, | 318 &self, |
319 ) -> Result<RefMut<OwningDirstateMap>, DirstateError> { | 319 ) -> Result<RefMut<OwningDirstateMap>, DirstateError> { |
320 self.dirstate_map.get_mut_or_init(self) | 320 self.dirstate_map.get_mut_or_init(self) |
321 } | 321 } |
322 | 322 |
323 pub fn changelog(&self) -> Result<Ref<Changelog>, RevlogError> { | 323 pub fn changelog(&self) -> Result<Ref<Changelog>, HgError> { |
324 self.changelog.get_or_init(self) | 324 self.changelog.get_or_init(self) |
325 } | 325 } |
326 | 326 |
327 pub fn changelog_mut(&self) -> Result<RefMut<Changelog>, RevlogError> { | 327 pub fn changelog_mut(&self) -> Result<RefMut<Changelog>, HgError> { |
328 self.changelog.get_mut_or_init(self) | 328 self.changelog.get_mut_or_init(self) |
329 } | 329 } |
330 | 330 |
331 pub fn manifestlog(&self) -> Result<Ref<Manifestlog>, RevlogError> { | 331 pub fn manifestlog(&self) -> Result<Ref<Manifestlog>, HgError> { |
332 self.manifestlog.get_or_init(self) | 332 self.manifestlog.get_or_init(self) |
333 } | 333 } |
334 | 334 |
335 pub fn manifestlog_mut(&self) -> Result<RefMut<Manifestlog>, RevlogError> { | 335 pub fn manifestlog_mut(&self) -> Result<RefMut<Manifestlog>, HgError> { |
336 self.manifestlog.get_mut_or_init(self) | 336 self.manifestlog.get_mut_or_init(self) |
337 } | 337 } |
338 | 338 |
339 /// Returns the manifest of the given revision | 339 /// Returns the manifest of the given revision |
340 pub fn manifest( | 340 pub fn manifest( |
347 let manifest_node = | 347 let manifest_node = |
348 Node::from_hex_for_repo(&changelog_entry.manifest_node()?)?; | 348 Node::from_hex_for_repo(&changelog_entry.manifest_node()?)?; |
349 manifest.get_node(manifest_node.into()) | 349 manifest.get_node(manifest_node.into()) |
350 } | 350 } |
351 | 351 |
352 pub fn filelog(&self, path: &HgPath) -> Result<Filelog, RevlogError> { | 352 pub fn filelog(&self, path: &HgPath) -> Result<Filelog, HgError> { |
353 Filelog::open(self, path) | 353 Filelog::open(self, path) |
354 } | 354 } |
355 } | 355 } |
356 | 356 |
357 /// Lazily-initialized component of `Repo` with interior mutability | 357 /// Lazily-initialized component of `Repo` with interior mutability |