@@ -145,7 +145,7 @@ impl Graph {
145
145
// It's OK to default-initialise this here as overlays are only used when redoing
146
146
// the traversal.
147
147
let ( _repo, meta, _entrypoint) = Overlay :: default ( ) . into_parts ( repo, meta) ;
148
- graph. insert_root ( branch_segment_from_name_and_meta (
148
+ graph. insert_segment_set_entrypoint ( branch_segment_from_name_and_meta (
149
149
Some ( ( ref_name, None ) ) ,
150
150
& meta,
151
151
None ,
@@ -337,7 +337,7 @@ impl Graph {
337
337
dangerously_skip_postprocessing_for_debugging,
338
338
} ;
339
339
if tip_is_not_workspace_commit {
340
- let current = graph. insert_root ( branch_segment_from_name_and_meta (
340
+ let current = graph. insert_segment_set_entrypoint ( branch_segment_from_name_and_meta (
341
341
None ,
342
342
meta,
343
343
Some ( ( & ctx. refs_by_id , tip) ) ,
@@ -388,7 +388,16 @@ impl Graph {
388
388
// The limits for the target ref and the worktree ref are synced so they can always find each other,
389
389
// while being able to stop when the entrypoint is included.
390
390
ws_segment. metadata = Some ( SegmentMetadata :: Workspace ( ws_meta) ) ;
391
- let ws_segment = graph. insert_root ( ws_segment) ;
391
+ let ws_segment = graph. insert_segment ( ws_segment) ;
392
+ if graph. entrypoint . is_none ( )
393
+ && graph
394
+ . entrypoint_ref
395
+ . as_ref ( )
396
+ . zip ( ref_name. as_ref ( ) )
397
+ . is_some_and ( |( a, b) | a == b)
398
+ {
399
+ graph. entrypoint = Some ( ( ws_segment, None ) ) ;
400
+ }
392
401
// As workspaces typically have integration branches which can help us to stop the traversal,
393
402
// pick these up first.
394
403
_ = next. push_front_exhausted ( (
@@ -403,45 +412,45 @@ impl Graph {
403
412
) ) ;
404
413
405
414
if let Some ( ( target_ref, target_ref_id, local_tip_info) ) = target {
406
- let target_segment = graph. insert_root ( branch_segment_from_name_and_meta (
415
+ let target_segment = graph. insert_segment ( branch_segment_from_name_and_meta (
407
416
Some ( ( target_ref, None ) ) ,
408
417
meta,
409
418
None ,
410
419
) ?) ;
411
- let ( local_sidx, local_goal) = if let Some ( ( local_ref_name, target_local_tip) ) =
412
- local_tip_info
413
- {
414
- let local_sidx = graph. insert_root ( branch_segment_from_name_and_meta_sibling (
415
- None ,
416
- Some ( target_segment) ,
417
- meta,
418
- Some ( ( & ctx. refs_by_id , target_local_tip) ) ,
419
- ) ?) ;
420
- // We use auto-naming based on ambiguity - if the name ends up something else,
421
- // remove the nodes sibling link.
422
- let has_sibling_link = {
423
- let s = & mut graph[ local_sidx] ;
424
- if s. ref_name . as_ref ( ) . is_none_or ( |rn| rn != & local_ref_name) {
425
- s. sibling_segment_id = None ;
426
- false
427
- } else {
428
- true
429
- }
420
+ let ( local_sidx, local_goal) =
421
+ if let Some ( ( local_ref_name, target_local_tip) ) = local_tip_info {
422
+ let local_sidx =
423
+ graph. insert_segment ( branch_segment_from_name_and_meta_sibling (
424
+ None ,
425
+ Some ( target_segment) ,
426
+ meta,
427
+ Some ( ( & ctx. refs_by_id , target_local_tip) ) ,
428
+ ) ?) ;
429
+ // We use auto-naming based on ambiguity - if the name ends up something else,
430
+ // remove the nodes sibling link.
431
+ let has_sibling_link = {
432
+ let s = & mut graph[ local_sidx] ;
433
+ if s. ref_name . as_ref ( ) . is_none_or ( |rn| rn != & local_ref_name) {
434
+ s. sibling_segment_id = None ;
435
+ false
436
+ } else {
437
+ true
438
+ }
439
+ } ;
440
+ let goal = goals. flag_for ( target_local_tip) . unwrap_or_default ( ) ;
441
+ _ = next. push_front_exhausted ( (
442
+ target_local_tip,
443
+ CommitFlags :: NotInRemote | goal,
444
+ Instruction :: CollectCommit { into : local_sidx } ,
445
+ max_limit
446
+ . with_indirect_goal ( tip, & mut goals)
447
+ . without_allowance ( ) ,
448
+ ) ) ;
449
+ next. add_goal_to ( tip, goal) ;
450
+ ( has_sibling_link. then_some ( local_sidx) , goal)
451
+ } else {
452
+ ( None , CommitFlags :: empty ( ) )
430
453
} ;
431
- let goal = goals. flag_for ( target_local_tip) . unwrap_or_default ( ) ;
432
- _ = next. push_front_exhausted ( (
433
- target_local_tip,
434
- CommitFlags :: NotInRemote | goal,
435
- Instruction :: CollectCommit { into : local_sidx } ,
436
- max_limit
437
- . with_indirect_goal ( tip, & mut goals)
438
- . without_allowance ( ) ,
439
- ) ) ;
440
- next. add_goal_to ( tip, goal) ;
441
- ( has_sibling_link. then_some ( local_sidx) , goal)
442
- } else {
443
- ( None , CommitFlags :: empty ( ) )
444
- } ;
445
454
_ = next. push_front_exhausted ( (
446
455
target_ref_id,
447
456
CommitFlags :: Integrated ,
@@ -468,7 +477,7 @@ impl Graph {
468
477
// have to adjust the existing queue item.
469
478
existing_segment
470
479
} else {
471
- let extra_target_sidx = graph. insert_root ( branch_segment_from_name_and_meta (
480
+ let extra_target_sidx = graph. insert_segment ( branch_segment_from_name_and_meta (
472
481
None ,
473
482
meta,
474
483
Some ( ( & ctx. refs_by_id , extra_target) ) ,
@@ -517,7 +526,7 @@ impl Graph {
517
526
meta,
518
527
Some ( ( & ctx. refs_by_id , segment_tip. detach ( ) ) ) ,
519
528
) ?;
520
- let segment = graph. insert_root ( segment) ;
529
+ let segment = graph. insert_segment ( segment) ;
521
530
_ = next. push_back_exhausted ( (
522
531
segment_tip. detach ( ) ,
523
532
CommitFlags :: NotInRemote ,
0 commit comments