repo: make all base_repo() functions return &Arc<ReadonlyRepo>

This is to prepare for a `Repo` trait implemented for
`Arc<ReadonlyRepo>` (not for `ReadonlyRepo` itself).
This commit is contained in:
Martin von Zweigbergk 2023-02-15 18:15:50 -08:00 committed by Martin von Zweigbergk
parent 8a067282c8
commit b7dad291df
3 changed files with 7 additions and 7 deletions

View file

@ -53,15 +53,15 @@ use crate::{backend, op_store};
// RepoRef?
#[derive(Clone, Copy)]
pub enum RepoRef<'a> {
Readonly(&'a ReadonlyRepo),
Readonly(&'a Arc<ReadonlyRepo>),
Mutable(&'a MutableRepo),
}
impl<'a> RepoRef<'a> {
pub fn base_repo(&self) -> &ReadonlyRepo {
pub fn base_repo(&self) -> &Arc<ReadonlyRepo> {
match self {
RepoRef::Readonly(repo) => repo,
RepoRef::Mutable(repo) => repo.base_repo.as_ref(),
RepoRef::Readonly(repo) => &repo,
RepoRef::Mutable(repo) => &repo.base_repo,
}
}
@ -245,7 +245,7 @@ impl ReadonlyRepo {
}
}
pub fn as_repo_ref(&self) -> RepoRef {
pub fn as_repo_ref<'a>(self: &'a Arc<Self>) -> RepoRef<'a> {
RepoRef::Readonly(self)
}

View file

@ -48,7 +48,7 @@ impl Transaction {
}
}
pub fn base_repo(&self) -> &ReadonlyRepo {
pub fn base_repo(&self) -> &Arc<ReadonlyRepo> {
self.mut_repo.base_repo()
}

View file

@ -1017,7 +1017,7 @@ impl WorkspaceCommandTransaction<'_> {
self.helper
}
pub fn base_repo(&self) -> &ReadonlyRepo {
pub fn base_repo(&self) -> &Arc<ReadonlyRepo> {
self.tx.base_repo()
}