Skip to content

Commit

Permalink
index_store: add more scope to write_index()
Browse files Browse the repository at this point in the history
This is more consistent with the other method and it makes some extension operations easier, by giving access to the OpStore and other relevant context for custom index extensions.
  • Loading branch information
torquestomp committed May 10, 2024
1 parent 3307696 commit 3a0929b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/src/default_index/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,14 @@ impl IndexStore for DefaultIndexStore {
fn write_index(
&self,
index: Box<dyn MutableIndex>,
op_id: &OperationId,
op: &Operation,
) -> Result<Box<dyn ReadonlyIndex>, IndexWriteError> {
let index = index
.into_any()
.downcast::<DefaultMutableIndex>()
.expect("index to merge in must be a DefaultMutableIndex");
let index_segment = self
.save_mutable_index(*index, op_id)
.save_mutable_index(*index, op.id())
.map_err(|err| IndexWriteError(err.into()))?;
Ok(Box::new(DefaultReadonlyIndex::from_segment(index_segment)))
}
Expand Down
3 changes: 1 addition & 2 deletions lib/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use thiserror::Error;
use crate::backend::{ChangeId, CommitId};
use crate::commit::Commit;
use crate::object_id::{HexPrefix, PrefixResolution};
use crate::op_store::OperationId;
use crate::operation::Operation;
use crate::revset::{ResolvedExpression, Revset, RevsetEvaluationError};
use crate::store::Store;
Expand Down Expand Up @@ -67,7 +66,7 @@ pub trait IndexStore: Send + Sync + Debug {
fn write_index(
&self,
index: Box<dyn MutableIndex>,
op_id: &OperationId,
op: &Operation,
) -> Result<Box<dyn ReadonlyIndex>, IndexWriteError>;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl Transaction {

let index = base_repo
.index_store()
.write_index(mut_index, operation.id())
.write_index(mut_index, &operation)
.unwrap();
UnpublishedOperation::new(&base_repo.loader(), operation, view, index)
}
Expand Down

0 comments on commit 3a0929b

Please sign in to comment.