Walk deleted forward edges from `parent` to find a dead vertex that was deleted by both `left_change` and `right_change`. Returns the content bytes of the ancestor, or `None` if no shared dead vertex could be found.
(
&self,
parent: &GraphNode<NodeId>,
left_change: NodeId,
right_change: NodeId,
)
| 363 | /// Returns the content bytes of the ancestor, or `None` if no shared |
| 364 | /// dead vertex could be found. |
| 365 | fn find_ancestor_content( |
| 366 | &self, |
| 367 | parent: &GraphNode<NodeId>, |
| 368 | left_change: NodeId, |
| 369 | right_change: NodeId, |
| 370 | ) -> Result<Option<Vec<u8>>, SemanticMergeError> { |
| 371 | // Look at all forward edges from the parent, including deleted ones. |
| 372 | let forward_edges = self.txn.iter_forward(*parent, true)?; |
| 373 | |
| 374 | for edge in &forward_edges { |
| 375 | if !edge.kind.is_deleted() { |
| 376 | continue; |
| 377 | } |
| 378 | |
| 379 | let dead_vertex = self.txn.find_block(edge.dest)?; |
| 380 | |
| 381 | // Check whether this vertex was deleted by BOTH competing changes |
| 382 | // by examining its parent edges. |
| 383 | let parent_edges = self.txn.iter_parents(dead_vertex, true)?; |
| 384 | |
| 385 | let mut deleted_by_left = false; |
| 386 | let mut deleted_by_right = false; |
| 387 | |
| 388 | for parent_edge in &parent_edges { |
| 389 | if parent_edge.kind.is_deleted() { |
| 390 | if parent_edge.introduced_by == left_change { |
| 391 | deleted_by_left = true; |
| 392 | } |
| 393 | if parent_edge.introduced_by == right_change { |
| 394 | deleted_by_right = true; |
| 395 | } |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | if deleted_by_left && deleted_by_right { |
| 400 | let content = self.get_vertex_content(&dead_vertex)?; |
| 401 | return Ok(Some(content)); |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | Ok(None) |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | /// Check whether `sub`'s tokens are a subsequence of `sup`'s tokens. |
no test coverage detected