From b7dad291dfe9ac48ae734fdd200a1f585594a408 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 15 Feb 2023 18:15:50 -0800 Subject: [PATCH] repo: make all base_repo() functions return `&Arc` This is to prepare for a `Repo` trait implemented for `Arc` (not for `ReadonlyRepo` itself). --- lib/src/repo.rs | 10 +++++----- lib/src/transaction.rs | 2 +- src/cli_util.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/src/repo.rs b/lib/src/repo.rs index 9b0512626..ba45ffcf8 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -53,15 +53,15 @@ use crate::{backend, op_store}; // RepoRef? #[derive(Clone, Copy)] pub enum RepoRef<'a> { - Readonly(&'a ReadonlyRepo), + Readonly(&'a Arc), Mutable(&'a MutableRepo), } impl<'a> RepoRef<'a> { - pub fn base_repo(&self) -> &ReadonlyRepo { + pub fn base_repo(&self) -> &Arc { 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) -> RepoRef<'a> { RepoRef::Readonly(self) } diff --git a/lib/src/transaction.rs b/lib/src/transaction.rs index 16db09a60..9e096af4c 100644 --- a/lib/src/transaction.rs +++ b/lib/src/transaction.rs @@ -48,7 +48,7 @@ impl Transaction { } } - pub fn base_repo(&self) -> &ReadonlyRepo { + pub fn base_repo(&self) -> &Arc { self.mut_repo.base_repo() } diff --git a/src/cli_util.rs b/src/cli_util.rs index 6bf651b4b..6969331ee 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -1017,7 +1017,7 @@ impl WorkspaceCommandTransaction<'_> { self.helper } - pub fn base_repo(&self) -> &ReadonlyRepo { + pub fn base_repo(&self) -> &Arc { self.tx.base_repo() }