@@ -28,22 +28,40 @@ where
2828 tips : impl IntoIterator < Item = impl Into < ObjectId > > ,
2929 ends : Option < impl IntoIterator < Item = impl Into < ObjectId > > > ,
3030 ) -> Self {
31- let tips = tips. into_iter ( ) . map ( Into :: into) . collect :: < Vec < _ > > ( ) ;
32- let ends = ends
33- . map ( |e| e. into_iter ( ) . map ( Into :: into) . collect :: < Vec < _ > > ( ) )
34- . unwrap_or_default ( ) ;
31+ Self :: new ( find) . with_tips ( tips) . with_ends ( ends. into_iter ( ) . flatten ( ) )
32+ }
3533
34+ /// Create a new `Builder` for a [`Topo`] that reads commits from a
35+ /// repository with `find`.
36+ pub fn new ( find : Find ) -> Self {
3637 Self {
3738 commit_graph : Default :: default ( ) ,
3839 find,
3940 sorting : Default :: default ( ) ,
4041 parents : Default :: default ( ) ,
41- tips,
42- ends,
42+ tips : Default :: default ( ) ,
43+ ends : Default :: default ( ) ,
4344 predicate : |_| true ,
4445 }
4546 }
4647
48+ /// Add commits to start reading from.
49+ ///
50+ /// The behavior is similar to specifying additional `ends` in `git rev-list --topo-order ^ends tips`.
51+ pub fn with_tips ( mut self , tips : impl IntoIterator < Item = impl Into < ObjectId > > ) -> Self {
52+ self . tips . extend ( tips. into_iter ( ) . map ( Into :: into) ) ;
53+ self
54+ }
55+
56+ /// Add commits ending the traversal.
57+ ///
58+ /// These commits themselves will not be read, i.e. the behavior is similar to specifying additional
59+ /// `ends` in `git rev-list --topo-order ^ends tips`.
60+ pub fn with_ends ( mut self , ends : impl IntoIterator < Item = impl Into < ObjectId > > ) -> Self {
61+ self . ends . extend ( ends. into_iter ( ) . map ( Into :: into) ) ;
62+ self
63+ }
64+
4765 /// Set a `predicate` to filter out revisions from the walk. Can be used to
4866 /// implement e.g. filtering on paths or time. This does *not* exclude the
4967 /// parent(s) of a revision that is excluded. Specify a revision as an 'end'
0 commit comments