diff --git a/radicle-cob/src/change_graph.rs b/radicle-cob/src/change_graph.rs index c98a90b4..f7fbc8a3 100644 --- a/radicle-cob/src/change_graph.rs +++ b/radicle-cob/src/change_graph.rs @@ -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)) diff --git a/radicle-dag/src/lib.rs b/radicle-dag/src/lib.rs index ce40811d..6bd95f0d 100644 --- a/radicle-dag/src/lib.rs +++ b/radicle-dag/src/lib.rs @@ -103,6 +103,11 @@ impl Dag { } } + /// 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> { self.graph.get(key)