@@ -155,6 +155,7 @@ pub struct Platform<'repo> {
155
155
/// The owning repository.
156
156
pub repo : & ' repo Repository ,
157
157
pub ( crate ) tips : Vec < ObjectId > ,
158
+ pub ( crate ) hidden : Vec < ObjectId > ,
158
159
pub ( crate ) boundary : Vec < ObjectId > ,
159
160
pub ( crate ) sorting : Sorting ,
160
161
pub ( crate ) parents : gix_traverse:: commit:: Parents ,
@@ -167,6 +168,7 @@ impl<'repo> Platform<'repo> {
167
168
revision:: walk:: Platform {
168
169
repo,
169
170
tips : tips. into_iter ( ) . map ( Into :: into) . collect ( ) ,
171
+ hidden : Vec :: new ( ) ,
170
172
sorting : Default :: default ( ) ,
171
173
parents : Default :: default ( ) ,
172
174
use_commit_graph : None ,
@@ -210,13 +212,13 @@ impl Platform<'_> {
210
212
self
211
213
}
212
214
213
- /// Don't cross the given `ids` during traversal.
215
+ /// Don't cross the given `ids` (commits) during traversal.
214
216
///
215
217
/// Note that this forces the [sorting](Self::sorting()) to [`ByCommitTimeCutoff`](Sorting::ByCommitTimeCutoff)
216
218
/// configured with the oldest available commit time, ensuring that no commits older than the oldest of `ids` will be returned either.
217
219
/// Also note that commits that can't be accessed or are missing are simply ignored for the purpose of obtaining the cutoff date.
218
220
///
219
- /// A boundary is distinctly different from exclusive refsepcs `^branch-to-not-list` in Git log.
221
+ /// A boundary is distinctly different from exclusive revspecs `^branch-to-not-list` in Git log.
220
222
///
221
223
/// If this is not desired, [set the sorting](Self::sorting()) to something else right after this call.
222
224
pub fn with_boundary ( mut self , ids : impl IntoIterator < Item = impl Into < ObjectId > > ) -> Self {
@@ -242,6 +244,20 @@ impl Platform<'_> {
242
244
}
243
245
self
244
246
}
247
+
248
+ /// Don't cross the given `tips` (commits) during traversal or return them, and also don't return any of their ancestors.
249
+ ///
250
+ /// This allows achieving revspecs like `^branch-to-not-list`, where the commit behind that name would be passed as `ids`.
251
+ ///
252
+ /// In other words, each of the `tips` acts like a starting point for an iteration that will paint commits as unwanted, and
253
+ /// wanted commits cannot cross it.
254
+ ///
255
+ /// The side effect of this is that commits can't be returned immediately as one still has to wait and see if they may be unwanted later.
256
+ /// This makes traversals with hidden commits more costly, with a chance to traverse all commits if the hidden and non-hidden commits are disjoint.
257
+ pub fn with_hidden ( mut self , tips : impl IntoIterator < Item = impl Into < ObjectId > > ) -> Self {
258
+ self . hidden = tips. into_iter ( ) . map ( Into :: into) . collect ( ) ;
259
+ self
260
+ }
245
261
}
246
262
247
263
/// Produce the iterator
@@ -262,6 +278,7 @@ impl<'repo> Platform<'repo> {
262
278
use_commit_graph,
263
279
commit_graph,
264
280
mut boundary,
281
+ hidden,
265
282
} = self ;
266
283
boundary. sort ( ) ;
267
284
Ok ( revision:: Walk {
@@ -301,6 +318,7 @@ impl<'repo> Platform<'repo> {
301
318
} )
302
319
. sorting ( sorting. into_simple ( ) . expect ( "for now there is nothing else" ) ) ?
303
320
. parents ( parents)
321
+ . hide ( hidden) ?
304
322
. commit_graph (
305
323
commit_graph. or ( use_commit_graph
306
324
. map_or_else ( || self . repo . config . may_use_commit_graph ( ) , Ok ) ?
0 commit comments