MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / find_ancestor_content

Method find_ancestor_content

atomic-core/src/merge/engine.rs:336–377  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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.

Callers 1

try_mergeMethod · 0.80

Calls 5

iter_forwardMethod · 0.80
iter_parentsMethod · 0.80
get_vertex_contentMethod · 0.80
is_deletedMethod · 0.45
find_blockMethod · 0.45

Tested by

no test coverage detected