repo: make OpHeadsStore accessible directly on ReadonlyRepo

We can now get rid of `MutableView::update_op_heads()`.
This commit is contained in:
Martin von Zweigbergk 2021-03-10 23:14:00 -08:00
parent 212dd35d01
commit 82a3ff6ef8
3 changed files with 10 additions and 8 deletions

View file

@ -112,6 +112,7 @@ pub struct ReadonlyRepo {
wc_path: PathBuf,
store: Arc<StoreWrapper>,
op_store: Arc<dyn OpStore>,
op_heads_store: Arc<OpHeadsStore>,
settings: RepoSettings,
index_store: Arc<IndexStore>,
index: Mutex<Option<Arc<ReadonlyIndex>>>,
@ -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<OpHeadsStore> {
&self.op_heads_store
}
pub fn index_store(&self) -> &Arc<IndexStore> {
&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),

View file

@ -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
}

View file

@ -95,7 +95,6 @@ pub struct ReadonlyView {
pub struct MutableView {
store: Arc<StoreWrapper>,
op_store: Arc<dyn OpStore>,
op_heads_store: Arc<OpHeadsStore>,
base_op_id: OperationId,
data: op_store::View,
}
@ -235,6 +234,7 @@ impl ReadonlyView {
op_heads_store: Arc<OpHeadsStore>,
index_store: Arc<IndexStore>,
) -> 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)
}
}