##// END OF EJS Templates
hgk: colorize commits by authors...
Georg.Koltermann@mscsoftware.com -
r5464:7dafd9ab default
parent child Browse files
Show More
@@ -338,7 +338,10 b' proc parsecommit {id contents listed old'
338 338 }
339 339
340 340 proc readrefs {} {
341 global tagids idtags headids idheads tagcontents env
341 global tagids idtags headids idheads tagcontents env curid
342
343 set curid [exec $env(HG) --config ui.report_untrusted=false id]
344 regexp -- {[[:xdigit:]]+} $curid curid
342 345
343 346 set tags [exec $env(HG) --config ui.report_untrusted=false tags]
344 347 regsub -all "\r\n" $tags "\n" tags
@@ -641,13 +644,14 b' proc click {w} {'
641 644 proc savestuff {w} {
642 645 global canv canv2 canv3 ctext cflist mainfont textfont
643 646 global stuffsaved findmergefiles gaudydiff maxgraphpct
644 global maxwidth
647 global maxwidth authorcolors curidfont
645 648
646 649 if {$stuffsaved} return
647 650 if {![winfo viewable .]} return
648 651 catch {
649 652 set f [open "~/.gitk-new" w]
650 653 puts $f [list set mainfont $mainfont]
654 puts $f [list set curidfont $curidfont]
651 655 puts $f [list set textfont $textfont]
652 656 puts $f [list set findmergefiles $findmergefiles]
653 657 puts $f [list set gaudydiff $gaudydiff]
@@ -665,6 +669,23 b' proc savestuff {w} {'
665 669 set wid [expr {([winfo width $cflist] - 11) \
666 670 / [font measure [$cflist cget -font] "0"]}]
667 671 puts $f "set geometry(cflistw) $wid"
672 puts $f "#"
673 puts $f "# authorcolors format:"
674 puts $f "#"
675 puts $f "# zero or more sublists of"
676 puts $f "#"
677 puts $f "# { regex color }"
678 puts $f "#"
679 puts $f "# followed by a list of colors"
680 puts $f "#"
681 puts $f "# If the commit author matches a regex in a sublist,"
682 puts $f "# the commit will be colored by that color"
683 puts $f "# otherwise the next unused entry from the list of colors"
684 puts $f "# will be assigned to this commit and also all other commits"
685 puts $f "# of the same author. When the list of colors is exhausted,"
686 puts $f "# the last entry will be reused."
687 puts $f "#"
688 puts $f "set authorcolors {$authorcolors}"
668 689 close $f
669 690 file rename -force "~/.gitk-new" "~/.gitk"
670 691 }
@@ -757,6 +778,35 b' Use and redistribute under the terms of '
757 778 pack $w.ok -side bottom
758 779 }
759 780
781 set aunextcolor 0
782 proc assignauthorcolor {name} {
783 global authorcolors aucolormap aunextcolor
784 if [info exists aucolormap($name)] return
785
786 set randomcolors {black}
787 for {set i 0} {$i < [llength $authorcolors]} {incr i} {
788 set col [lindex $authorcolors $i]
789 if {[llength $col] > 1} {
790 set re [lindex $col 0]
791 set c [lindex $col 1]
792 if {[regexp -- $re $name]} {
793 set aucolormap($name) $c
794 return
795 }
796 } else {
797 set randomcolors [lrange $authorcolors $i end]
798 break
799 }
800 }
801
802 set ncolors [llength $randomcolors]
803 set c [lindex $randomcolors $aunextcolor]
804 if {[incr aunextcolor] >= $ncolors} {
805 incr aunextcolor -1
806 }
807 set aucolormap($name) $c
808 }
809
760 810 proc assigncolor {id} {
761 811 global commitinfo colormap commcolors colors nextcolor
762 812 global parents nparents children nchildren
@@ -894,6 +944,7 b' proc drawcommitline {level} {'
894 944 global lineno lthickness mainline mainlinearrow sidelines
895 945 global commitlisted rowtextx idpos lastuse displist
896 946 global oldnlines olddlevel olddisplist
947 global aucolormap curid curidfont
897 948
898 949 incr numcommits
899 950 incr lineno
@@ -952,14 +1003,25 b' proc drawcommitline {level} {'
952 1003 }
953 1004 set headline [lindex $commitinfo($id) 0]
954 1005 set name [lindex $commitinfo($id) 1]
1006 assignauthorcolor $name
1007 set fg $aucolormap($name)
1008 if {$id == $curid} {
1009 set fn $curidfont
1010 } else {
1011 set fn $mainfont
1012 }
1013
955 1014 set date [lindex $commitinfo($id) 2]
956 1015 set linehtag($lineno) [$canv create text $xt $y1 -anchor w \
957 -text $headline -font $mainfont ]
1016 -text $headline -font $fn \
1017 -fill $fg]
958 1018 $canv bind $linehtag($lineno) <<B3>> "rowmenu %X %Y $id"
959 1019 set linentag($lineno) [$canv2 create text 3 $y1 -anchor w \
960 -text $name -font $namefont]
1020 -text $name -font $namefont \
1021 -fill $fg]
961 1022 set linedtag($lineno) [$canv3 create text 3 $y1 -anchor w \
962 -text $date -font $mainfont]
1023 -text $date -font $mainfont \
1024 -fill $fg]
963 1025
964 1026 set olddlevel $level
965 1027 set olddisplist $displist
@@ -3089,9 +3151,10 b' proc redisplay {} {'
3089 3151
3090 3152 proc incrfont {inc} {
3091 3153 global mainfont namefont textfont ctext canv phase
3092 global stopped entries
3154 global stopped entries curidfont
3093 3155 unmarkmatches
3094 3156 set mainfont [lreplace $mainfont 1 1 [expr {[lindex $mainfont 1] + $inc}]]
3157 set curidfont [lreplace $curidfont 1 1 [expr {[lindex $curidfont 1] + $inc}]]
3095 3158 set namefont [lreplace $namefont 1 1 [expr {[lindex $namefont 1] + $inc}]]
3096 3159 set textfont [lreplace $textfont 1 1 [expr {[lindex $textfont 1] + $inc}]]
3097 3160 setcoords
@@ -3772,6 +3835,7 b' set diffopts "-U 5 -p"'
3772 3835 set wrcomcmd "\"\$HG\" --config ui.report_untrusted=false debug-diff-tree --stdin -p --pretty"
3773 3836
3774 3837 set mainfont {Helvetica 9}
3838 set curidfont {}
3775 3839 set textfont {Courier 9}
3776 3840 set findmergefiles 0
3777 3841 set gaudydiff 0
@@ -3779,9 +3843,16 b' set maxgraphpct 50'
3779 3843 set maxwidth 16
3780 3844
3781 3845 set colors {green red blue magenta darkgrey brown orange}
3846 set authorcolors {
3847 deeppink mediumorchid blue burlywood4 goldenrod slateblue red2 navy dimgrey
3848 }
3782 3849
3783 3850 catch {source ~/.gitk}
3784 3851
3852 if {$curidfont == ""} { # initialize late based on current mainfont
3853 set curidfont "$mainfont bold italic underline"
3854 }
3855
3785 3856 set namefont $mainfont
3786 3857 if {$boldnames} {
3787 3858 lappend namefont bold
General Comments 0
You need to be logged in to leave comments. Login now