@@ -25,7 +25,7 @@ use lib::core::node_descriptors::{
25
25
} ;
26
26
use lib:: git:: { GitRunInfo , Repo } ;
27
27
28
- pub use graph:: { make_smartlog_graph, SmartlogGraph } ;
28
+ pub use graph:: { make_custom_smartlog_graph , make_smartlog_graph, SmartlogGraph , SmartlogVariant } ;
29
29
pub use render:: { render_graph, SmartlogOptions } ;
30
30
31
31
use crate :: opts:: Revset ;
@@ -211,7 +211,23 @@ mod graph {
211
211
}
212
212
}
213
213
214
- /// Construct the smartlog graph for the repo.
214
+ /// What kind of smartlog is desired?
215
+ #[ derive( Debug ) ]
216
+ pub enum SmartlogVariant {
217
+ /// A smartlog with all commits connected back to the main branch.
218
+ Connected ,
219
+
220
+ /// A smartlog with only the specified set of a commits.
221
+ Sparse ,
222
+ }
223
+
224
+ impl Default for SmartlogVariant {
225
+ fn default ( ) -> Self {
226
+ SmartlogVariant :: Connected
227
+ }
228
+ }
229
+
230
+ /// Construct the default smartlog graph for the repo.
215
231
#[ instrument]
216
232
pub fn make_smartlog_graph < ' repo > (
217
233
effects : & Effects ,
@@ -220,13 +236,41 @@ mod graph {
220
236
event_replayer : & EventReplayer ,
221
237
event_cursor : EventCursor ,
222
238
commits : & CommitSet ,
239
+ ) -> eyre:: Result < SmartlogGraph < ' repo > > {
240
+ make_custom_smartlog_graph (
241
+ effects,
242
+ repo,
243
+ dag,
244
+ event_replayer,
245
+ event_cursor,
246
+ commits,
247
+ SmartlogVariant :: default ( ) ,
248
+ )
249
+ }
250
+
251
+ /// Construct a specific kind of smartlog graph for the repo.
252
+ #[ instrument]
253
+ pub fn make_custom_smartlog_graph < ' repo > (
254
+ effects : & Effects ,
255
+ repo : & ' repo Repo ,
256
+ dag : & Dag ,
257
+ event_replayer : & EventReplayer ,
258
+ event_cursor : EventCursor ,
259
+ commits : & CommitSet ,
260
+ smartlog_variant : SmartlogVariant ,
223
261
) -> eyre:: Result < SmartlogGraph < ' repo > > {
224
262
let ( effects, _progress) = effects. start_operation ( OperationType :: MakeGraph ) ;
225
263
226
264
let mut graph = {
227
265
let ( effects, _progress) = effects. start_operation ( OperationType :: WalkCommits ) ;
228
266
229
267
let public_commits = dag. query_public_commits ( ) ?;
268
+
269
+ let commits = match smartlog_variant {
270
+ SmartlogVariant :: Connected => commits,
271
+ SmartlogVariant :: Sparse => commits,
272
+ } ;
273
+
230
274
for oid in commit_set_to_vec ( commits) ? {
231
275
mark_commit_reachable ( repo, oid) ?;
232
276
}
@@ -557,9 +601,9 @@ pub fn smartlog(
557
601
& references_snapshot,
558
602
) ?;
559
603
560
- let revset = match revset {
561
- Some ( revset) => revset. clone ( ) ,
562
- None => Revset :: default ( ) ,
604
+ let ( revset, smartlog_variant ) = match revset {
605
+ Some ( revset) => ( revset. clone ( ) , SmartlogVariant :: Sparse ) ,
606
+ None => ( Revset :: default ( ) , SmartlogVariant :: Connected ) ,
563
607
} ;
564
608
565
609
let commits = match resolve_commits ( effects, & repo, & mut dag, & [ revset] , resolve_revset_options)
@@ -577,13 +621,14 @@ pub fn smartlog(
577
621
}
578
622
} ;
579
623
580
- let graph = make_smartlog_graph (
624
+ let graph = make_custom_smartlog_graph (
581
625
effects,
582
626
& repo,
583
627
& dag,
584
628
& event_replayer,
585
629
event_cursor,
586
630
& commits,
631
+ smartlog_variant,
587
632
) ?;
588
633
589
634
let lines = render_graph (
0 commit comments