ok/jj
1
0
Fork 0
forked from mirrors/jj

op_heads_store: propagate errors from OpStore

This commit is contained in:
Martin von Zweigbergk 2023-08-31 11:01:47 -07:00 committed by Martin von Zweigbergk
parent 134881c670
commit be08707a3a

View file

@ -89,7 +89,7 @@ pub fn resolve_op_heads<E>(
if op_heads.len() == 1 { if op_heads.len() == 1 {
let operation_id = op_heads.pop().unwrap(); let operation_id = op_heads.pop().unwrap();
let operation = op_store.read_operation(&operation_id).unwrap(); let operation = op_store.read_operation(&operation_id)?;
return Ok(Operation::new(op_store.clone(), operation_id, operation)); return Ok(Operation::new(op_store.clone(), operation_id, operation));
} }
@ -110,17 +110,17 @@ pub fn resolve_op_heads<E>(
if op_head_ids.len() == 1 { if op_head_ids.len() == 1 {
let op_head_id = op_head_ids[0].clone(); let op_head_id = op_head_ids[0].clone();
let op_head = op_store.read_operation(&op_head_id).unwrap(); let op_head = op_store.read_operation(&op_head_id)?;
return Ok(Operation::new(op_store.clone(), op_head_id, op_head)); return Ok(Operation::new(op_store.clone(), op_head_id, op_head));
} }
let op_heads = op_head_ids let op_heads = op_head_ids
.iter() .iter()
.map(|op_id: &OperationId| { .map(|op_id: &OperationId| -> Result<Operation, OpStoreError> {
let data = op_store.read_operation(op_id).unwrap(); let data = op_store.read_operation(op_id)?;
Operation::new(op_store.clone(), op_id.clone(), data) Ok(Operation::new(op_store.clone(), op_id.clone(), data))
}) })
.collect_vec(); .try_collect()?;
let mut op_heads = op_heads_store.handle_ancestor_ops(op_heads); let mut op_heads = op_heads_store.handle_ancestor_ops(op_heads);
// Return without creating a merge operation // Return without creating a merge operation