op_heads_store: return operations sorted by timestamp (#111)

It's cheap to sort them, so let's have them always sorted, so all
callers can rely on that order.
This commit is contained in:
Martin von Zweigbergk 2022-03-26 10:32:49 -07:00 committed by Martin von Zweigbergk
parent d62cc15ff0
commit d45a25b1ee
2 changed files with 2 additions and 2 deletions

View file

@ -184,6 +184,7 @@ impl OpHeadsStore {
return Ok(OpHeads::Single(op_heads.pop().unwrap()));
}
op_heads.sort_by_key(|op| op.store_operation().metadata.end_time.timestamp.clone());
Ok(OpHeads::Unresolved {
locked_op_heads,
op_heads,

View file

@ -387,9 +387,8 @@ impl RepoLoader {
fn merge_op_heads(
&self,
user_settings: &UserSettings,
mut op_heads: Vec<Operation>,
op_heads: Vec<Operation>,
) -> UnpublishedOperation {
op_heads.sort_by_key(|op| op.store_operation().metadata.end_time.timestamp.clone());
let base_repo = self.load_at(&op_heads[0]);
let mut tx = base_repo.start_transaction("resolve concurrent operations");
for other_op_head in op_heads.into_iter().skip(1) {