11use super :: utils:: graphrow:: {
22 SYM_BRANCH_DOWN , SYM_BRANCH_UP , SYM_BRANCH_UP_RIGHT , SYM_COMMIT ,
33 SYM_COMMIT_BRANCH , SYM_COMMIT_MERGE , SYM_COMMIT_STASH ,
4- SYM_COMMIT_UNCOMMITTED , SYM_CROSS , SYM_HORIZONTAL , SYM_MERGE_BRIDGE_END ,
5- SYM_MERGE_BRIDGE_MID , SYM_MERGE_BRIDGE_START , SYM_SPACE ,
6- SYM_VERTICAL , SYM_VERTICAL_DOTTED ,
4+ SYM_COMMIT_UNCOMMITTED , SYM_CROSS , SYM_HORIZONTAL ,
5+ SYM_MERGE_BRIDGE_END , SYM_MERGE_BRIDGE_MID ,
6+ SYM_MERGE_BRIDGE_START , SYM_SPACE , SYM_VERTICAL ,
7+ SYM_VERTICAL_DOTTED ,
78} ;
89use super :: utils:: logitems:: { ItemBatch , LogEntry } ;
910use crate :: {
@@ -21,7 +22,7 @@ use crate::{
2122} ;
2223use anyhow:: Result ;
2324use asyncgit:: {
24- graph:: { ConnType , GraphRow } ,
25+ graph:: { ConnectionType , GraphRow } ,
2526 sync:: {
2627 self , checkout_commit, BranchDetails , BranchInfo , CommitId ,
2728 RepoPathRef , Tags ,
@@ -502,50 +503,78 @@ impl CommitList {
502503 }
503504 let ( sym, graph_color) = match conn {
504505 None => ( SYM_SPACE , Color :: Reset ) ,
505- Some ( ( ConnType :: Vertical , color_idx) ) => {
506- ( SYM_VERTICAL , GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] )
507- }
508- Some ( ( ConnType :: VerticalDotted , color_idx) ) => {
509- ( SYM_VERTICAL_DOTTED , GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] )
510- }
511- Some ( ( ConnType :: Cross , color_idx) ) => {
512- ( SYM_CROSS , GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] )
513- }
514- Some ( ( ConnType :: CommitNormal , color_idx) ) => {
515- ( SYM_COMMIT , GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] )
516- }
517- Some ( ( ConnType :: CommitBranch , color_idx) ) => {
518- ( SYM_COMMIT_BRANCH , GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] )
519- }
520- Some ( ( ConnType :: CommitMerge , color_idx) ) => {
521- ( SYM_COMMIT_MERGE , GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] )
522- }
523- Some ( ( ConnType :: CommitStash , color_idx) ) => {
524- ( SYM_COMMIT_STASH , GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] )
525- }
526- Some ( ( ConnType :: CommitUncommitted , color_idx) ) => {
527- ( SYM_COMMIT_UNCOMMITTED , GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] )
528- }
529- Some ( ( ConnType :: MergeBridgeStart , color_idx) ) => {
530- ( SYM_MERGE_BRIDGE_START , GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] )
531- }
532- Some ( ( ConnType :: MergeBridgeMid , color_idx) ) => {
533- ( SYM_MERGE_BRIDGE_MID , GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] )
534- }
535- Some ( ( ConnType :: MergeBridgeEnd , color_idx) ) => {
536- ( SYM_MERGE_BRIDGE_END , GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] )
537- }
538- Some ( ( ConnType :: BranchDown , color_idx) ) => {
539- ( SYM_BRANCH_DOWN , GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] )
540- }
541- Some ( ( ConnType :: BranchUp , color_idx) ) => {
542- ( SYM_BRANCH_UP , GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] )
543- }
544- Some ( ( ConnType :: BranchUpRight , color_idx) ) => {
545- ( SYM_BRANCH_UP_RIGHT , GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] )
546- }
506+ Some ( ( ConnectionType :: Vertical , color_idx) ) => (
507+ SYM_VERTICAL ,
508+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
509+ ) ,
510+ Some ( ( ConnectionType :: VerticalDotted , color_idx) ) => (
511+ SYM_VERTICAL_DOTTED ,
512+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
513+ ) ,
514+ Some ( ( ConnectionType :: Cross , color_idx) ) => (
515+ SYM_CROSS ,
516+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
517+ ) ,
518+ Some ( ( ConnectionType :: BranchUpMergeStart , color_idx) ) => (
519+ SYM_BRANCH_UP , // Reusing '┛'
520+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
521+ ) ,
522+ Some ( (
523+ ConnectionType :: BranchUpRightMergeEnd ,
524+ color_idx,
525+ ) ) => (
526+ SYM_BRANCH_UP_RIGHT , // Reusing '┗'
527+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
528+ ) ,
529+ Some ( ( ConnectionType :: CommitNormal , color_idx) ) => (
530+ SYM_COMMIT ,
531+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
532+ ) ,
533+ Some ( ( ConnectionType :: CommitBranch , color_idx) ) => (
534+ SYM_COMMIT_BRANCH ,
535+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
536+ ) ,
537+ Some ( ( ConnectionType :: CommitMerge , color_idx) ) => (
538+ SYM_COMMIT_MERGE ,
539+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
540+ ) ,
541+ Some ( ( ConnectionType :: CommitStash , color_idx) ) => (
542+ SYM_COMMIT_STASH ,
543+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
544+ ) ,
545+ Some ( ( ConnectionType :: CommitUncommitted , color_idx) ) => (
546+ SYM_COMMIT_UNCOMMITTED ,
547+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
548+ ) ,
549+ Some ( ( ConnectionType :: MergeBridgeStart , color_idx) ) => (
550+ SYM_MERGE_BRIDGE_START ,
551+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
552+ ) ,
553+ Some ( ( ConnectionType :: MergeBridgeMid , color_idx) ) => (
554+ SYM_MERGE_BRIDGE_MID ,
555+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
556+ ) ,
557+ Some ( ( ConnectionType :: MergeBridgeEnd , color_idx) ) => (
558+ SYM_MERGE_BRIDGE_END ,
559+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
560+ ) ,
561+ Some ( ( ConnectionType :: BranchDown , color_idx) ) => (
562+ SYM_BRANCH_DOWN ,
563+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
564+ ) ,
565+ Some ( ( ConnectionType :: BranchUp , color_idx) ) => (
566+ SYM_BRANCH_UP ,
567+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
568+ ) ,
569+ Some ( ( ConnectionType :: BranchUpRight , color_idx) ) => (
570+ SYM_BRANCH_UP_RIGHT ,
571+ GRAPH_COLORS [ color_idx % GRAPH_COLORS . len ( ) ] ,
572+ ) ,
547573 } ;
548- spans. push ( Span :: styled ( sym, Style :: default ( ) . fg ( graph_color) ) ) ;
574+ spans. push ( Span :: styled (
575+ sym,
576+ Style :: default ( ) . fg ( graph_color) ,
577+ ) ) ;
549578
550579 // Spacer
551580 let mut is_bridge_lane = false ;
@@ -554,15 +583,21 @@ impl CommitList {
554583 if let Some ( ( from, to) ) = row. merge_bridge {
555584 if lane_index >= from && lane_index < to {
556585 is_bridge_lane = true ;
557- spacer_color = GRAPH_COLORS [ row. commit_lane % GRAPH_COLORS . len ( ) ] ;
586+ spacer_color = GRAPH_COLORS
587+ [ row. commit_lane % GRAPH_COLORS . len ( ) ] ;
558588 }
559589 }
560590
561591 for & ( from, to) in & row. branches {
562592 if lane_index >= from && lane_index < to {
563593 is_bridge_lane = true ;
564- let branch_lane = if row. commit_lane == from { to } else { from } ;
565- spacer_color = GRAPH_COLORS [ branch_lane % GRAPH_COLORS . len ( ) ] ;
594+ let branch_lane = if row. commit_lane == from {
595+ to
596+ } else {
597+ from
598+ } ;
599+ spacer_color = GRAPH_COLORS
600+ [ branch_lane % GRAPH_COLORS . len ( ) ] ;
566601 }
567602 }
568603
@@ -788,7 +823,7 @@ impl CommitList {
788823 if !matches ! (
789824 conn,
790825 None | Some ( (
791- ConnType :: MergeBridgeMid ,
826+ ConnectionType :: MergeBridgeMid ,
792827 _
793828 ) )
794829 ) {
@@ -849,7 +884,7 @@ impl CommitList {
849884 local_branches,
850885 self . remote_branches_string ( e) ,
851886 & self . theme ,
852- width,
887+ width. into ( ) ,
853888 now,
854889 marked,
855890 & empty_lanes,
@@ -1330,12 +1365,11 @@ mod tests {
13301365 is_merge : false ,
13311366 is_branch_tip : false ,
13321367 is_stash : false ,
1333- lanes : vec ! [ Some ( ( ConnType :: CommitNormal , 0 ) ) ] ,
1368+ lanes : vec ! [ Some ( ( ConnectionType :: CommitNormal , 0 ) ) ] ,
13341369 merge_bridge : None ,
13351370 branches : vec ! [ ] ,
13361371 } ;
1337- let empty_lanes = std:: collections:: HashSet :: new ( ) ;
1338- let spans = cl. build_graph_spans ( & row, 1 , & empty_lanes) ;
1372+ let spans = cl. build_graph_spans ( & row, 1 ) ;
13391373
13401374 assert_eq ! ( spans. len( ) , 2 ) ;
13411375 assert_eq ! ( spans[ 0 ] . content, Cow :: from( SYM_COMMIT ) ) ;
0 commit comments