@@ -28,22 +28,40 @@ where
28
28
tips : impl IntoIterator < Item = impl Into < ObjectId > > ,
29
29
ends : Option < impl IntoIterator < Item = impl Into < ObjectId > > > ,
30
30
) -> 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
+ }
35
33
34
+ /// Create a new `Builder` for a [`Topo`] that reads commits from a
35
+ /// repository with `find`.
36
+ pub fn new ( find : Find ) -> Self {
36
37
Self {
37
38
commit_graph : Default :: default ( ) ,
38
39
find,
39
40
sorting : Default :: default ( ) ,
40
41
parents : Default :: default ( ) ,
41
- tips,
42
- ends,
42
+ tips : Default :: default ( ) ,
43
+ ends : Default :: default ( ) ,
43
44
predicate : |_| true ,
44
45
}
45
46
}
46
47
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
+
47
65
/// Set a `predicate` to filter out revisions from the walk. Can be used to
48
66
/// implement e.g. filtering on paths or time. This does *not* exclude the
49
67
/// parent(s) of a revision that is excluded. Specify a revision as an 'end'
0 commit comments