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.
This commit is contained in:
Martin von Zweigbergk 2021-01-31 18:07:37 -08:00
parent bf53c6c506
commit 2d03b514fc
2 changed files with 4 additions and 14 deletions

View file

@ -31,7 +31,7 @@ use crate::settings::{RepoSettings, UserSettings};
use crate::store; use crate::store;
use crate::store::{Store, StoreError}; use crate::store::{Store, StoreError};
use crate::store_wrapper::StoreWrapper; use crate::store_wrapper::StoreWrapper;
use crate::transaction::Transaction; use crate::transaction::{MutableRepo, Transaction};
use crate::view::{ReadonlyView, View}; use crate::view::{ReadonlyView, View};
use crate::working_copy::WorkingCopy; use crate::working_copy::WorkingCopy;
@ -284,12 +284,8 @@ impl ReadonlyRepo {
} }
pub fn start_transaction(&self, description: &str) -> Transaction { pub fn start_transaction(&self, description: &str) -> Transaction {
Transaction::new( let mut_repo = MutableRepo::new(self, &self.view, &self.evolution.as_ref().unwrap());
&self, Transaction::new(mut_repo, description)
&self.view,
&self.evolution.as_ref().unwrap(),
description,
)
} }
pub fn reload(&mut self) { pub fn reload(&mut self) {

View file

@ -41,13 +41,7 @@ pub struct MutableRepo<'r> {
} }
impl<'r> Transaction<'r> { impl<'r> Transaction<'r> {
pub fn new( pub fn new(mut_repo: Arc<MutableRepo<'r>>, description: &str) -> Transaction<'r> {
repo: &'r ReadonlyRepo,
view: &ReadonlyView,
evolution: &ReadonlyEvolution<'r>,
description: &str,
) -> Transaction<'r> {
let mut_repo = MutableRepo::new(repo, view, evolution);
Transaction { Transaction {
repo: Some(mut_repo), repo: Some(mut_repo),
description: description.to_owned(), description: description.to_owned(),