From 736a0e7442cc7376baac200cd602796594efee3f Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 29 Sep 2021 09:38:54 -0700 Subject: [PATCH] Transaction: don't wrap MutableRepo in Arc I think this was a vestige from the time when `MutableEvolution` had a back-reference into `MutableRepo` (at least I think it used to be that way). --- lib/src/repo.rs | 6 +++--- lib/src/transaction.rs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/src/repo.rs b/lib/src/repo.rs index 5f440b150..34f6dcacf 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -528,16 +528,16 @@ impl MutableRepo { index: Arc, view: &View, evolution: Option<&Arc>, - ) -> Arc { + ) -> MutableRepo { let mut_view = view.start_modification(); let mut_index = MutableIndex::incremental(index); let mut_evolution = evolution.map(|evolution| evolution.start_modification()); - Arc::new(MutableRepo { + MutableRepo { base_repo, index: mut_index, view: mut_view, evolution: Mutex::new(mut_evolution), - }) + } } pub fn as_repo_ref(&self) -> RepoRef { diff --git a/lib/src/transaction.rs b/lib/src/transaction.rs index a4cc92c61..dc0b6f417 100644 --- a/lib/src/transaction.rs +++ b/lib/src/transaction.rs @@ -26,7 +26,7 @@ use crate::view::View; use crate::working_copy::WorkingCopy; pub struct Transaction { - repo: Option>, + repo: Option, parents: Vec, description: String, start_time: Timestamp, @@ -35,7 +35,7 @@ pub struct Transaction { } impl Transaction { - pub fn new(mut_repo: Arc, description: &str) -> Transaction { + pub fn new(mut_repo: MutableRepo, description: &str) -> Transaction { let parents = vec![mut_repo.base_repo().op_id().clone()]; Transaction { repo: Some(mut_repo), @@ -60,7 +60,7 @@ impl Transaction { } pub fn mut_repo(&mut self) -> &mut MutableRepo { - Arc::get_mut(self.repo.as_mut().unwrap()).unwrap() + self.repo.as_mut().unwrap() } /// Writes the transaction to the operation store and publishes it. @@ -72,7 +72,7 @@ impl Transaction { /// That means that a repo can be loaded at the operation, but the /// operation will not be seen when loading the repo at head. pub fn write(mut self) -> UnpublishedOperation { - let mut_repo = Arc::try_unwrap(self.repo.take().unwrap()).ok().unwrap(); + let mut_repo = self.repo.take().unwrap(); let base_repo = mut_repo.base_repo().clone(); let (mut_index, view, maybe_mut_evolution) = mut_repo.consume(); let maybe_evolution =