forked from mirrors/jj
index_store: add more scope to write_index()
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.
This commit is contained in:
parent
3307696ba8
commit
3a0929b876
3 changed files with 4 additions and 5 deletions
|
@ -359,14 +359,14 @@ impl IndexStore for DefaultIndexStore {
|
||||||
fn write_index(
|
fn write_index(
|
||||||
&self,
|
&self,
|
||||||
index: Box<dyn MutableIndex>,
|
index: Box<dyn MutableIndex>,
|
||||||
op_id: &OperationId,
|
op: &Operation,
|
||||||
) -> Result<Box<dyn ReadonlyIndex>, IndexWriteError> {
|
) -> Result<Box<dyn ReadonlyIndex>, IndexWriteError> {
|
||||||
let index = index
|
let index = index
|
||||||
.into_any()
|
.into_any()
|
||||||
.downcast::<DefaultMutableIndex>()
|
.downcast::<DefaultMutableIndex>()
|
||||||
.expect("index to merge in must be a DefaultMutableIndex");
|
.expect("index to merge in must be a DefaultMutableIndex");
|
||||||
let index_segment = self
|
let index_segment = self
|
||||||
.save_mutable_index(*index, op_id)
|
.save_mutable_index(*index, op.id())
|
||||||
.map_err(|err| IndexWriteError(err.into()))?;
|
.map_err(|err| IndexWriteError(err.into()))?;
|
||||||
Ok(Box::new(DefaultReadonlyIndex::from_segment(index_segment)))
|
Ok(Box::new(DefaultReadonlyIndex::from_segment(index_segment)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ use thiserror::Error;
|
||||||
use crate::backend::{ChangeId, CommitId};
|
use crate::backend::{ChangeId, CommitId};
|
||||||
use crate::commit::Commit;
|
use crate::commit::Commit;
|
||||||
use crate::object_id::{HexPrefix, PrefixResolution};
|
use crate::object_id::{HexPrefix, PrefixResolution};
|
||||||
use crate::op_store::OperationId;
|
|
||||||
use crate::operation::Operation;
|
use crate::operation::Operation;
|
||||||
use crate::revset::{ResolvedExpression, Revset, RevsetEvaluationError};
|
use crate::revset::{ResolvedExpression, Revset, RevsetEvaluationError};
|
||||||
use crate::store::Store;
|
use crate::store::Store;
|
||||||
|
@ -67,7 +66,7 @@ pub trait IndexStore: Send + Sync + Debug {
|
||||||
fn write_index(
|
fn write_index(
|
||||||
&self,
|
&self,
|
||||||
index: Box<dyn MutableIndex>,
|
index: Box<dyn MutableIndex>,
|
||||||
op_id: &OperationId,
|
op: &Operation,
|
||||||
) -> Result<Box<dyn ReadonlyIndex>, IndexWriteError>;
|
) -> Result<Box<dyn ReadonlyIndex>, IndexWriteError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ impl Transaction {
|
||||||
|
|
||||||
let index = base_repo
|
let index = base_repo
|
||||||
.index_store()
|
.index_store()
|
||||||
.write_index(mut_index, operation.id())
|
.write_index(mut_index, &operation)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
UnpublishedOperation::new(&base_repo.loader(), operation, view, index)
|
UnpublishedOperation::new(&base_repo.loader(), operation, view, index)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue