From 59148a2043f0f502edfb895e19843b7fab6efeac Mon Sep 17 00:00:00 2001 From: Julian Ganz Date: Mon, 9 Dec 2024 13:10:29 +0100 Subject: [PATCH] feat: add `topo::Builder::new` fn for creating a bare builder Previously, the only way to create a `Builder` would be via `Builder::from_iters`. That fn takes as arguments both the tips and ends, and used to be the only possibility for specifying either of them during the building process. However, in order to enhance the builder- likeness of `Builder`, we recently introduced fns `with_tips` and `with_ends` for adding additional tips and ends. With those fns, the only component which needs to be supplied up-front is `find`. Users can specify and empty `Iterator` and `None` for `tips` and `ends` respectively when calling `Builder::from_iters` and add additional tips and ends at their leisure, without the need to chain `Iterator`s or collecting them in some external data structure. Now, calling `Builder::from_iters` with a empty lists for tips and ends is a bit awkward. Thus, we provide a new method for creating a bare `Builder`. --- gix-traverse/src/commit/topo/init.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gix-traverse/src/commit/topo/init.rs b/gix-traverse/src/commit/topo/init.rs index cb3b7a172c1..d784eeba8a8 100644 --- a/gix-traverse/src/commit/topo/init.rs +++ b/gix-traverse/src/commit/topo/init.rs @@ -44,6 +44,20 @@ where } } + /// Create a new `Builder` for a [`Topo`] that reads commits from a + /// repository with `find`. + pub fn new(find: Find) -> Self { + Self { + commit_graph: Default::default(), + find, + sorting: Default::default(), + parents: Default::default(), + tips: Default::default(), + ends: Default::default(), + predicate: |_| true, + } + } + /// Add commits to start reading from. The behavior is similar to specifying /// additional `ends` in `git rev-list --topo-order ^ends tips`. pub fn with_tips(mut self, tips: impl IntoIterator>) -> Self {