mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-30 08:05:05 +00:00
index_store: take OperationId when writing new index
By taking an `OperationId` argument to `IndexStore::write_index()`, we can remove `associate_file_with_operation()` from the trait. That simplifies the interace a little bit. The reason I noticed this was that I'm trying to extract a trait for `IndexStore`, and the word "file" in it is too specific for e.g. a cloud-based implementation.
This commit is contained in:
parent
346e3c849b
commit
4c5695f0cd
2 changed files with 11 additions and 6 deletions
|
@ -75,8 +75,14 @@ impl IndexStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_index(&self, index: MutableIndex) -> io::Result<Arc<ReadonlyIndex>> {
|
pub fn write_index(
|
||||||
index.save_in(self.dir.clone())
|
&self,
|
||||||
|
index: MutableIndex,
|
||||||
|
op_id: &OperationId,
|
||||||
|
) -> io::Result<Arc<ReadonlyIndex>> {
|
||||||
|
let index = index.save_in(self.dir.clone())?;
|
||||||
|
self.associate_file_with_operation(&index, op_id)?;
|
||||||
|
Ok(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_index_at_operation(
|
fn load_index_at_operation(
|
||||||
|
@ -161,7 +167,7 @@ impl IndexStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Records a link from the given operation to the this index version.
|
/// Records a link from the given operation to the this index version.
|
||||||
pub fn associate_file_with_operation(
|
fn associate_file_with_operation(
|
||||||
&self,
|
&self,
|
||||||
index: &ReadonlyIndex,
|
index: &ReadonlyIndex,
|
||||||
op_id: &OperationId,
|
op_id: &OperationId,
|
||||||
|
|
|
@ -97,7 +97,6 @@ impl Transaction {
|
||||||
);
|
);
|
||||||
let base_repo = mut_repo.base_repo().clone();
|
let base_repo = mut_repo.base_repo().clone();
|
||||||
let (mut_index, view) = mut_repo.consume();
|
let (mut_index, view) = mut_repo.consume();
|
||||||
let index = base_repo.index_store().write_index(mut_index).unwrap();
|
|
||||||
|
|
||||||
let view_id = base_repo.op_store().write_view(view.store_view()).unwrap();
|
let view_id = base_repo.op_store().write_view(view.store_view()).unwrap();
|
||||||
self.op_metadata.end_time = self.end_time.unwrap_or_else(Timestamp::now);
|
self.op_metadata.end_time = self.end_time.unwrap_or_else(Timestamp::now);
|
||||||
|
@ -113,9 +112,9 @@ impl Transaction {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let operation = Operation::new(base_repo.op_store().clone(), new_op_id, store_operation);
|
let operation = Operation::new(base_repo.op_store().clone(), new_op_id, store_operation);
|
||||||
|
|
||||||
base_repo
|
let index = base_repo
|
||||||
.index_store()
|
.index_store()
|
||||||
.associate_file_with_operation(&index, operation.id())
|
.write_index(mut_index, operation.id())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
UnpublishedOperation::new(base_repo.loader(), operation, view, index)
|
UnpublishedOperation::new(base_repo.loader(), operation, view, index)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue