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,
)
| 334 | /// Returns the content bytes of the ancestor, or `None` if no shared |
| 335 | /// dead vertex could be found. |
| 336 | fn find_ancestor_content( |
| 337 | &self, |
| 338 | parent: &GraphNode<NodeId>, |
| 339 | left_change: NodeId, |
| 340 | right_change: NodeId, |
| 341 | ) -> Result<Option<Vec<u8>>, PristineError> { |
| 342 | // Look at all forward edges from the parent, including deleted ones. |
| 343 | let forward_edges = self.txn.iter_forward(*parent, true)?; |
| 344 | |
| 345 | for edge in &forward_edges { |
| 346 | if !edge.kind.is_deleted() { |
| 347 | continue; |
| 348 | } |
| 349 | |
| 350 | let dead_vertex = self.txn.find_block(edge.dest)?; |
| 351 | |
| 352 | // Check whether this vertex was deleted by BOTH competing changes |
| 353 | // by examining its parent edges. |
| 354 | let parent_edges = self.txn.iter_parents(dead_vertex, true)?; |
| 355 | |
| 356 | let mut deleted_by_left = false; |
| 357 | let mut deleted_by_right = false; |
| 358 | |
| 359 | for parent_edge in &parent_edges { |
| 360 | if parent_edge.kind.is_deleted() { |
| 361 | if parent_edge.introduced_by == left_change { |
| 362 | deleted_by_left = true; |
| 363 | } |
| 364 | if parent_edge.introduced_by == right_change { |
| 365 | deleted_by_right = true; |
| 366 | } |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | if deleted_by_left && deleted_by_right { |
| 371 | let content = self.get_vertex_content(&dead_vertex)?; |
| 372 | return Ok(Some(content)); |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | Ok(None) |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | /// Check whether `sub`'s tokens are a subsequence of `sup`'s tokens. |
no test coverage detected