From 2d03b514fcdadbf3bab546fcb1768ea732e57c01 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 31 Jan 2021 18:07:37 -0800 Subject: [PATCH] transaction: move construction of MutableRepo out of Transaction::new() I'm about to move `MutableRepo` to the `repo` module and it will make more sense to have the construction of it there then. --- lib/src/repo.rs | 10 +++------- lib/src/transaction.rs | 8 +------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/src/repo.rs b/lib/src/repo.rs index 344b35724..d79ba0ecf 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -31,7 +31,7 @@ use crate::settings::{RepoSettings, UserSettings}; use crate::store; use crate::store::{Store, StoreError}; use crate::store_wrapper::StoreWrapper; -use crate::transaction::Transaction; +use crate::transaction::{MutableRepo, Transaction}; use crate::view::{ReadonlyView, View}; use crate::working_copy::WorkingCopy; @@ -284,12 +284,8 @@ impl ReadonlyRepo { } pub fn start_transaction(&self, description: &str) -> Transaction { - Transaction::new( - &self, - &self.view, - &self.evolution.as_ref().unwrap(), - description, - ) + let mut_repo = MutableRepo::new(self, &self.view, &self.evolution.as_ref().unwrap()); + Transaction::new(mut_repo, description) } pub fn reload(&mut self) { diff --git a/lib/src/transaction.rs b/lib/src/transaction.rs index 38aaf88f3..c0c78031c 100644 --- a/lib/src/transaction.rs +++ b/lib/src/transaction.rs @@ -41,13 +41,7 @@ pub struct MutableRepo<'r> { } impl<'r> Transaction<'r> { - pub fn new( - repo: &'r ReadonlyRepo, - view: &ReadonlyView, - evolution: &ReadonlyEvolution<'r>, - description: &str, - ) -> Transaction<'r> { - let mut_repo = MutableRepo::new(repo, view, evolution); + pub fn new(mut_repo: Arc>, description: &str) -> Transaction<'r> { Transaction { repo: Some(mut_repo), description: description.to_owned(),