From 82a3ff6ef8150cf6849b49ebda3ff9aca45d574f Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 10 Mar 2021 23:14:00 -0800 Subject: [PATCH] repo: make OpHeadsStore accessible directly on ReadonlyRepo We can now get rid of `MutableView::update_op_heads()`. --- lib/src/repo.rs | 9 ++++++++- lib/src/transaction.rs | 2 +- lib/src/view.rs | 7 +------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/src/repo.rs b/lib/src/repo.rs index 362ba4f0f..37fd4e3dc 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -112,6 +112,7 @@ pub struct ReadonlyRepo { wc_path: PathBuf, store: Arc, op_store: Arc, + op_heads_store: Arc, settings: RepoSettings, index_store: Arc, index: Mutex>>, @@ -224,7 +225,7 @@ impl ReadonlyRepo { let view = ReadonlyView::init( store.clone(), op_store.clone(), - op_heads_store, + op_heads_store.clone(), index_store.clone(), init_op_id, root_view, @@ -235,6 +236,7 @@ impl ReadonlyRepo { wc_path, store, op_store, + op_heads_store, settings: repo_settings, index_store, index: Mutex::new(None), @@ -327,6 +329,10 @@ impl ReadonlyRepo { &self.op_store } + pub fn op_heads_store(&self) -> &Arc { + &self.op_heads_store + } + pub fn index_store(&self) -> &Arc { &self.index_store } @@ -458,6 +464,7 @@ impl RepoLoader { wc_path: self.wc_path, store: self.store, op_store: self.op_store, + op_heads_store: self.op_heads_store, settings: self.repo_settings, index_store: self.index_store, index: Mutex::new(None), diff --git a/lib/src/transaction.rs b/lib/src/transaction.rs index 2e27f3937..185be89d6 100644 --- a/lib/src/transaction.rs +++ b/lib/src/transaction.rs @@ -130,7 +130,7 @@ impl<'r> Transaction<'r> { index_store .associate_file_with_operation(&index, operation.id()) .unwrap(); - mut_view.update_op_heads(&operation); + base_repo.op_heads_store().update_op_heads(&operation); self.closed = true; operation } diff --git a/lib/src/view.rs b/lib/src/view.rs index 0e669afb9..cbaa7dfbd 100644 --- a/lib/src/view.rs +++ b/lib/src/view.rs @@ -95,7 +95,6 @@ pub struct ReadonlyView { pub struct MutableView { store: Arc, op_store: Arc, - op_heads_store: Arc, base_op_id: OperationId, data: op_store::View, } @@ -235,6 +234,7 @@ impl ReadonlyView { op_heads_store: Arc, index_store: Arc, ) -> Self { + // TODO: We should probably move this get_single_op_head() call to ReadonlyRepo. let (op_id, _operation, view) = op_heads_store .get_single_op_head(&store, &op_store, &index_store) .unwrap(); @@ -285,7 +285,6 @@ impl ReadonlyView { MutableView { store: self.store.clone(), op_store: self.op_store.clone(), - op_heads_store: self.op_heads_store.clone(), base_op_id: self.op_id.clone(), data: self.data.clone(), } @@ -392,8 +391,4 @@ impl MutableView { let new_op_id = self.op_store.write_operation(&operation).unwrap(); Operation::new(self.op_store.clone(), new_op_id, operation) } - - pub fn update_op_heads(&self, op: &Operation) { - self.op_heads_store.update_op_heads(op) - } }