OpHeadsStore: check for fast-forward merge before calling merge_op_heads()

This is another little refactoring to prepare for using the
`Transaction` API in `merge_op_heads()`.
This commit is contained in:
Martin von Zweigbergk 2021-03-13 16:33:31 -08:00
parent 9452d17b75
commit f6488e2e9f

View file

@ -156,6 +156,15 @@ impl OpHeadsStore {
.collect();
let op_heads = self.handle_ancestor_ops(op_heads);
// Return without creating a merge operation
if op_heads.len() == 1 {
return Ok((
op_heads[0].id().clone(),
op_heads[0].store_operation().clone(),
op_heads[0].view().take_store_view(),
));
}
let (merge_operation_id, merge_operation, merged_view) =
merge_op_heads(repo_loader, op_heads)?;
self.add_op_head(&merge_operation_id);
@ -192,15 +201,6 @@ fn merge_op_heads(
let op_store = repo_loader.op_store();
let mut merged_view = op_store.read_view(first_op_head.view().id()).unwrap();
// Return without creating a merge operation
if op_heads.len() == 1 {
return Ok((
op_heads[0].id().clone(),
first_op_head.store_operation().clone(),
merged_view,
));
}
let neighbors_fn = |op: &Operation| op.parents();
let store = repo_loader.store();
let index_store = repo_loader.index_store();