diff --git a/crates/loro-core/src/dag.rs b/crates/loro-core/src/dag.rs index f28ad7eb..ee723438 100644 --- a/crates/loro-core/src/dag.rs +++ b/crates/loro-core/src/dag.rs @@ -353,24 +353,25 @@ where } } - // if top nodes are from the same client with different source, we find a shared node - if let Some((other_node, other_type)) = queue.peek() { - if node_type != *other_type && node.id.client_id == other_node.id.client_id { - if node_type != NodeType::Shared { - ans.push(ID { - client_id: node.id.client_id, - counter: node.id.counter.min(other_node.id.counter), - }); - node_type = NodeType::Shared; - } - match other_type { - NodeType::A => a_count -= 1, - NodeType::B => b_count -= 1, - NodeType::Shared => {} - } - queue.pop(); - } - } + // // if top nodes are from the same client with different source, we find a shared node + // if let Some((other_node, other_type)) = queue.peek() { + // if node_type != *other_type && node.id.client_id == other_node.id.client_id { + // if node_type != NodeType::Shared { + // debug_assert!(other_node.id.counter < node.id.counter); + // ans.push(ID { + // client_id: node.id.client_id, + // counter: other_node.id.counter, + // }); + // node_type = NodeType::Shared; + // } + // match other_type { + // NodeType::A => a_count -= 1, + // NodeType::B => b_count -= 1, + // NodeType::Shared => {} + // } + // queue.pop(); + // } + // } // detect whether client is visited by other if let Some((ctr, visited_type)) = visited.get_mut(&node.id.client_id) { diff --git a/crates/loro-core/src/dag/test.rs b/crates/loro-core/src/dag/test.rs index 424b71b4..5dd6d001 100644 --- a/crates/loro-core/src/dag/test.rs +++ b/crates/loro-core/src/dag/test.rs @@ -580,12 +580,12 @@ mod find_common_ancestors_proptest { fn issue() { if let Err(err) = test_mul_ancestors::<3>( 10, - vec![], vec![Interaction { - dag_idx: 4, - merge_with: Some(2), + dag_idx: 2, + merge_with: Some(5), len: 1, }], + vec![], ) { println!("{}", err); panic!(); @@ -681,7 +681,18 @@ mod find_common_ancestors_proptest { dags.push(TestDag::new(i as ClientID)); } - for interaction in before_merge_insertion { + for mut interaction in before_merge_insertion { + if interaction.dag_idx < N { + // cannot act on first N nodes + interaction.dag_idx = interaction.dag_idx % (dags.len() - N) + N; + } + if let Some(merge) = interaction.merge_with { + if interaction.dag_idx == merge { + let next_merge = (merge + 1) % dags.len(); + interaction.merge_with = Some(next_merge); + } + } + apply(interaction, &mut dags); }