cob: Don't overwrite nodes during traversal
By not checking if the node exists, if a node is traversed twice, the second instance of it gets overwritten, and all the edges get lost.
This commit is contained in:
parent
730eaa00ca
commit
3e9c3d2679
|
|
@ -130,8 +130,9 @@ impl GraphBuilder {
|
|||
let resource_commit = *change.resource();
|
||||
let commit_id = commit.id;
|
||||
|
||||
self.graph.node(commit_id, change);
|
||||
|
||||
if !self.graph.contains(&commit_id) {
|
||||
self.graph.node(commit_id, change);
|
||||
}
|
||||
commit.parents.into_iter().filter_map(move |parent| {
|
||||
if parent.id != resource_commit && !self.graph.has_dependency(&commit_id, &parent.id) {
|
||||
Some((parent, commit_id))
|
||||
|
|
|
|||
|
|
@ -103,6 +103,11 @@ impl<K: Eq + Copy + Hash, V> Dag<K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Check if the graph contains a node.
|
||||
pub fn contains(&self, key: &K) -> bool {
|
||||
self.graph.contains_key(key)
|
||||
}
|
||||
|
||||
/// Get a node.
|
||||
pub fn get(&self, key: &K) -> Option<&Node<K, V>> {
|
||||
self.graph.get(key)
|
||||
|
|
|
|||
Loading…
Reference in New Issue