@@ -49,7 +49,7 @@ pub trait Graph: Debug {
4949 /// Filter `nodes` to only include nodes that are not ancestors of any other
5050 /// node in `nodes`.
5151 #[ instrument]
52- fn ancestors_heads (
52+ fn simplify_success_bounds (
5353 & self ,
5454 nodes : HashSet < Self :: Node > ,
5555 ) -> Result < HashSet < Self :: Node > , Self :: Error > {
@@ -95,7 +95,7 @@ pub trait Graph: Debug {
9595 /// Filter `nodes` to only include nodes that are not descendants of any
9696 /// other node in `nodes`.
9797 #[ instrument]
98- fn descendants_roots (
98+ fn simplify_failure_bounds (
9999 & self ,
100100 nodes : HashSet < Self :: Node > ,
101101 ) -> Result < HashSet < Self :: Node > , Self :: Error > {
@@ -282,9 +282,16 @@ pub struct Search<G: Graph> {
282282}
283283
284284impl < G : Graph > Search < G > {
285- /// Construct a new search.
286- pub fn new ( graph : G , nodes : impl IntoIterator < Item = G :: Node > ) -> Self {
287- let nodes = nodes
285+ /// Construct a new search. The provided `graph` represents the universe of
286+ /// all nodes, and `nodes` represents a subset of that universe to search
287+ /// in. Only elements from `nodes` will be returned by `success_bounds` and
288+ /// `failure_bounds`.
289+ ///
290+ /// For example, `graph` might correspond to the entire source control
291+ /// directed acyclic graph, and `nodes` might correspond to a recent range
292+ /// of commits where the first one is passing and the last one is failing.
293+ pub fn new ( graph : G , search_nodes : impl IntoIterator < Item = G :: Node > ) -> Self {
294+ let nodes = search_nodes
288295 . into_iter ( )
289296 . map ( |node| ( node, Status :: Untested ) )
290297 . collect ( ) ;
@@ -304,7 +311,7 @@ impl<G: Graph> Search<G> {
304311 Status :: Untested | Status :: Failure | Status :: Indeterminate => None ,
305312 } )
306313 . collect :: < HashSet < _ > > ( ) ;
307- let success_bounds = self . graph . ancestors_heads ( success_nodes) ?;
314+ let success_bounds = self . graph . simplify_success_bounds ( success_nodes) ?;
308315 Ok ( success_bounds)
309316 }
310317
@@ -321,7 +328,7 @@ impl<G: Graph> Search<G> {
321328 Status :: Untested | Status :: Success | Status :: Indeterminate => None ,
322329 } )
323330 . collect :: < HashSet < _ > > ( ) ;
324- let failure_bounds = self . graph . descendants_roots ( failure_nodes) ?;
331+ let failure_bounds = self . graph . simplify_failure_bounds ( failure_nodes) ?;
325332 Ok ( failure_bounds)
326333 }
327334
0 commit comments