@@ -202,14 +202,14 @@ impl CommitList {
202202 }
203203
204204 ///
205- pub fn local_branches (
205+ pub const fn local_branches (
206206 & self ,
207207 ) -> & std:: collections:: BTreeMap < CommitId , Vec < BranchInfo > > {
208208 & self . local_branches
209209 }
210210
211211 ///
212- pub fn remote_branches (
212+ pub const fn remote_branches (
213213 & self ,
214214 ) -> & std:: collections:: BTreeMap < CommitId , Vec < BranchInfo > > {
215215 & self . remote_branches
@@ -590,26 +590,14 @@ impl CommitList {
590590 ) ;
591591
592592 if self . show_graph {
593- if let Some ( ref row) = e. graph {
594- txt. extend ( self . build_graph_spans (
595- row,
596- self . graph_col_width . get ( ) ,
597- empty_lanes,
598- ) ) ;
599- } else {
600- txt. push ( Span :: raw (
601- " " . repeat ( self . graph_col_width . get ( ) ) ,
602- ) ) ;
603- }
604- txt. push ( Span :: raw ( " " ) ) ;
593+ self . add_graph_spans ( e, & mut txt, empty_lanes) ;
605594 }
606595
607596 let normal = !self . items . highlighting ( )
608597 || ( self . items . highlighting ( ) && e. highlighted ) ;
609598
610- let splitter_txt = Cow :: from ( symbol:: EMPTY_SPACE ) ;
611599 let splitter = Span :: styled (
612- splitter_txt ,
600+ Cow :: from ( symbol :: EMPTY_SPACE ) ,
613601 if normal {
614602 theme. text ( true , selected)
615603 } else {
@@ -630,48 +618,87 @@ impl CommitList {
630618 txt. push ( splitter. clone ( ) ) ;
631619 }
632620
633- let style_hash = if normal {
634- theme. commit_hash ( selected)
635- } else {
636- theme. commit_unhighlighted ( )
637- } ;
638- let style_time = if normal {
639- theme. commit_time ( selected)
640- } else {
641- theme. commit_unhighlighted ( )
642- } ;
643- let style_author = if normal {
644- theme. commit_author ( selected)
645- } else {
646- theme. commit_unhighlighted ( )
647- } ;
648- let style_tags = if normal {
649- theme. tags ( selected)
650- } else {
651- theme. commit_unhighlighted ( )
652- } ;
653- let style_branches = if normal {
654- theme. branch ( selected, true )
621+ Self :: add_entry_details (
622+ e,
623+ & mut txt,
624+ selected,
625+ normal,
626+ theme,
627+ width,
628+ now,
629+ tags,
630+ local_branches,
631+ remote_branches,
632+ & splitter,
633+ ) ;
634+
635+ Line :: from ( txt)
636+ }
637+
638+ fn add_graph_spans < ' a > (
639+ & self ,
640+ e : & ' a LogEntry ,
641+ txt : & mut Vec < Span < ' a > > ,
642+ empty_lanes : & std:: collections:: HashSet < usize > ,
643+ ) {
644+ if let Some ( ref row) = e. graph {
645+ txt. extend ( self . build_graph_spans (
646+ row,
647+ self . graph_col_width . get ( ) ,
648+ empty_lanes,
649+ ) ) ;
655650 } else {
656- theme. commit_unhighlighted ( )
657- } ;
658- let style_msg = if normal {
659- theme. text ( true , selected)
651+ txt. push ( Span :: raw (
652+ " " . repeat ( self . graph_col_width . get ( ) ) ,
653+ ) ) ;
654+ }
655+ txt. push ( Span :: raw ( " " ) ) ;
656+ }
657+
658+ #[ allow( clippy:: too_many_arguments) ]
659+ fn add_entry_details < ' a > (
660+ e : & ' a LogEntry ,
661+ txt : & mut Vec < Span < ' a > > ,
662+ selected : bool ,
663+ normal : bool ,
664+ theme : & Theme ,
665+ width : usize ,
666+ now : DateTime < Local > ,
667+ tags : Option < String > ,
668+ local_branches : Option < String > ,
669+ remote_branches : Option < String > ,
670+ splitter : & Span < ' a > ,
671+ ) {
672+ let (
673+ style_hash,
674+ style_time,
675+ style_author,
676+ style_tags,
677+ style_branches,
678+ style_msg,
679+ ) = if normal {
680+ (
681+ theme. commit_hash ( selected) ,
682+ theme. commit_time ( selected) ,
683+ theme. commit_author ( selected) ,
684+ theme. tags ( selected) ,
685+ theme. branch ( selected, true ) ,
686+ theme. text ( true , selected) ,
687+ )
660688 } else {
661- theme. commit_unhighlighted ( )
689+ let s = theme. commit_unhighlighted ( ) ;
690+ ( s, s, s, s, s, s)
662691 } ;
663692
664693 // commit hash
665694 txt. push ( Span :: styled ( Cow :: from ( & * e. hash_short ) , style_hash) ) ;
666-
667695 txt. push ( splitter. clone ( ) ) ;
668696
669697 // commit timestamp
670698 txt. push ( Span :: styled (
671699 Cow :: from ( e. time_to_string ( now) ) ,
672700 style_time,
673701 ) ) ;
674-
675702 txt. push ( splitter. clone ( ) ) ;
676703
677704 let author_width =
@@ -680,7 +707,6 @@ impl CommitList {
680707
681708 // commit author
682709 txt. push ( Span :: styled ( author, style_author) ) ;
683-
684710 txt. push ( splitter. clone ( ) ) ;
685711
686712 // commit tags
@@ -698,7 +724,7 @@ impl CommitList {
698724 txt. push ( Span :: styled ( remote_branches, style_branches) ) ;
699725 }
700726
701- txt. push ( splitter) ;
727+ txt. push ( splitter. clone ( ) ) ;
702728
703729 let message_width = width. saturating_sub (
704730 txt. iter ( ) . map ( |span| span. content . len ( ) ) . sum ( ) ,
@@ -709,8 +735,6 @@ impl CommitList {
709735 format ! ( "{:message_width$}" , & e. msg) ,
710736 style_msg,
711737 ) ) ;
712-
713- Line :: from ( txt)
714738 }
715739
716740 fn get_text ( & self , height : usize , width : usize ) -> Vec < Line < ' _ > > {
@@ -1133,6 +1157,8 @@ mod tests {
11331157 std:: path:: PathBuf :: default ( ) ,
11341158 ) ) ,
11351159 queue : Queue :: default ( ) ,
1160+ show_graph : true ,
1161+ graph_col_width : Cell :: new ( 0 ) ,
11361162 }
11371163 }
11381164 }
@@ -1167,6 +1193,7 @@ mod tests {
11671193 time : 0 ,
11681194 author : String :: default ( ) ,
11691195 id : CommitId :: default ( ) ,
1196+ parents : Vec :: default ( ) . into ( ) ,
11701197 } ;
11711198 // This just creates a sequence of fake ordered ids
11721199 // 0000000000000000000000000000000000000000
0 commit comments