Skip to content

Commit 476ca63

Browse files
committed
gitk: Index [fnvr]highlights by id rather than row
This means that we don't have to keep clearing them out whenever we change the row numbers for some commits. Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent 7e92e25 commit 476ca63

File tree

1 file changed

+33
-40
lines changed

1 file changed

+33
-40
lines changed

gitk

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,6 @@ proc vtokcmp {v a b} {
661661

662662
proc modify_arc {v a {lim {}}} {
663663
global varctok vtokmod varcmod varcrow vupptr curview vrowmod varccommits
664-
global vhighlights nhighlights fhighlights rhighlights
665664

666665
set vtokmod($v) [lindex $varctok($v) $a]
667666
set varcmod($v) $a
@@ -680,10 +679,6 @@ proc modify_arc {v a {lim {}}} {
680679
set vrowmod($v) $r
681680
undolayout $r
682681
}
683-
catch {unset nhighlights}
684-
catch {unset fhighlights}
685-
catch {unset vhighlights}
686-
catch {unset rhighlights}
687682
}
688683

689684
proc update_arcrows {v} {
@@ -2850,20 +2845,20 @@ proc showview {n} {
28502845

28512846
# Stuff relating to the highlighting facility
28522847

2853-
proc ishighlighted {row} {
2848+
proc ishighlighted {id} {
28542849
global vhighlights fhighlights nhighlights rhighlights
28552850

2856-
if {[info exists nhighlights($row)] && $nhighlights($row) > 0} {
2857-
return $nhighlights($row)
2851+
if {[info exists nhighlights($id)] && $nhighlights($id) > 0} {
2852+
return $nhighlights($id)
28582853
}
2859-
if {[info exists vhighlights($row)] && $vhighlights($row) > 0} {
2860-
return $vhighlights($row)
2854+
if {[info exists vhighlights($id)] && $vhighlights($id) > 0} {
2855+
return $vhighlights($id)
28612856
}
2862-
if {[info exists fhighlights($row)] && $fhighlights($row) > 0} {
2863-
return $fhighlights($row)
2857+
if {[info exists fhighlights($id)] && $fhighlights($id) > 0} {
2858+
return $fhighlights($id)
28642859
}
2865-
if {[info exists rhighlights($row)] && $rhighlights($row) > 0} {
2866-
return $rhighlights($row)
2860+
if {[info exists rhighlights($id)] && $rhighlights($id) > 0} {
2861+
return $rhighlights($id)
28672862
}
28682863
return 0
28692864
}
@@ -2901,7 +2896,7 @@ proc unbolden {} {
29012896

29022897
set stillbold {}
29032898
foreach row $boldrows {
2904-
if {![ishighlighted $row]} {
2899+
if {![ishighlighted [commitonrow $row]]} {
29052900
bolden $row mainfont
29062901
} else {
29072902
lappend stillbold $row
@@ -2911,7 +2906,7 @@ proc unbolden {} {
29112906
}
29122907

29132908
proc addvhighlight {n} {
2914-
global hlview viewcomplete curview vhl_done vhighlights commitidx
2909+
global hlview viewcomplete curview vhl_done commitidx
29152910

29162911
if {[info exists hlview]} {
29172912
delvhighlight
@@ -2950,7 +2945,7 @@ proc vhighlightmore {} {
29502945
if {![highlighted $row]} {
29512946
bolden $row mainfontbold
29522947
}
2953-
set vhighlights($row) 1
2948+
set vhighlights($id) 1
29542949
}
29552950
}
29562951
}
@@ -2961,12 +2956,12 @@ proc askvhighlight {row id} {
29612956
global hlview vhighlights iddrawn
29622957

29632958
if {[commitinview $id $hlview]} {
2964-
if {[info exists iddrawn($id)] && ![ishighlighted $row]} {
2959+
if {[info exists iddrawn($id)] && ![ishighlighted $id]} {
29652960
bolden $row mainfontbold
29662961
}
2967-
set vhighlights($row) 1
2962+
set vhighlights($id) 1
29682963
} else {
2969-
set vhighlights($row) 0
2964+
set vhighlights($id) 0
29702965
}
29712966
}
29722967

@@ -3104,7 +3099,7 @@ proc askfilehighlight {row id} {
31043099
global filehighlight fhighlights fhl_list
31053100

31063101
lappend fhl_list $id
3107-
set fhighlights($row) -1
3102+
set fhighlights($id) -1
31083103
puts $filehighlight $id
31093104
}
31103105

@@ -3122,18 +3117,16 @@ proc readfhighlight {} {
31223117
if {$i < 0} continue
31233118
for {set j 0} {$j < $i} {incr j} {
31243119
set id [lindex $fhl_list $j]
3125-
if {[commitinview $id $curview]} {
3126-
set fhighlights([rowofcommit $id]) 0
3127-
}
3120+
set fhighlights($id) 0
31283121
}
31293122
set fhl_list [lrange $fhl_list [expr {$i+1}] end]
31303123
if {$line eq {}} continue
31313124
if {![commitinview $line $curview]} continue
31323125
set row [rowofcommit $line]
3133-
if {[info exists iddrawn($line)] && ![ishighlighted $row]} {
3126+
if {[info exists iddrawn($line)] && ![ishighlighted $line]} {
31343127
bolden $row mainfontbold
31353128
}
3136-
set fhighlights($row) 1
3129+
set fhighlights($line) 1
31373130
}
31383131
if {[eof $filehighlight]} {
31393132
# strange...
@@ -3182,7 +3175,7 @@ proc askfindhighlight {row id} {
31823175
}
31833176
}
31843177
if {$isbold && [info exists iddrawn($id)]} {
3185-
if {![ishighlighted $row]} {
3178+
if {![ishighlighted $id]} {
31863179
bolden $row mainfontbold
31873180
if {$isbold > 1} {
31883181
bolden_name $row mainfontbold
@@ -3192,7 +3185,7 @@ proc askfindhighlight {row id} {
31923185
markrowmatches $row $id
31933186
}
31943187
}
3195-
set nhighlights($row) $isbold
3188+
set nhighlights($id) $isbold
31963189
}
31973190

31983191
proc markrowmatches {row id} {
@@ -3230,7 +3223,7 @@ proc vrel_change {name ix op} {
32303223
# prepare for testing whether commits are descendents or ancestors of a
32313224
proc rhighlight_sel {a} {
32323225
global descendent desc_todo ancestor anc_todo
3233-
global highlight_related rhighlights
3226+
global highlight_related
32343227

32353228
catch {unset descendent}
32363229
set desc_todo [list $a]
@@ -3337,11 +3330,11 @@ proc askrelhighlight {row id} {
33373330
}
33383331
}
33393332
if {[info exists iddrawn($id)]} {
3340-
if {$isbold && ![ishighlighted $row]} {
3333+
if {$isbold && ![ishighlighted $id]} {
33413334
bolden $row mainfontbold
33423335
}
33433336
}
3344-
set rhighlights($row) $isbold
3337+
set rhighlights($id) $isbold
33453338
}
33463339

33473340
# Graph layout functions
@@ -4408,7 +4401,7 @@ proc drawcmittext {id row col} {
44084401
set date [formatdate $date]
44094402
set font mainfont
44104403
set nfont mainfont
4411-
set isbold [ishighlighted $row]
4404+
set isbold [ishighlighted $id]
44124405
if {$isbold > 0} {
44134406
lappend boldrows $row
44144407
set font mainfontbold
@@ -4445,16 +4438,16 @@ proc drawcmitrow {row} {
44454438
if {$row >= $numcommits} return
44464439

44474440
set id [lindex $displayorder $row]
4448-
if {[info exists hlview] && ![info exists vhighlights($row)]} {
4441+
if {[info exists hlview] && ![info exists vhighlights($id)]} {
44494442
askvhighlight $row $id
44504443
}
4451-
if {[info exists filehighlight] && ![info exists fhighlights($row)]} {
4444+
if {[info exists filehighlight] && ![info exists fhighlights($id)]} {
44524445
askfilehighlight $row $id
44534446
}
4454-
if {$findpattern ne {} && ![info exists nhighlights($row)]} {
4447+
if {$findpattern ne {} && ![info exists nhighlights($id)]} {
44554448
askfindhighlight $row $id
44564449
}
4457-
if {$highlight_related ne [mc "None"] && ![info exists rhighlights($row)]} {
4450+
if {$highlight_related ne [mc "None"] && ![info exists rhighlights($id)]} {
44584451
askrelhighlight $row $id
44594452
}
44604453
if {![info exists iddrawn($id)]} {
@@ -5045,15 +5038,15 @@ proc findmore {} {
50455038
set arowend [expr {$arow + [llength $ids]}]
50465039
}
50475040
set id [lindex $ids [expr {$l - $arow}]]
5048-
if {![info exists fhighlights($l)]} {
5049-
# this sets fhighlights($l) to -1
5041+
if {![info exists fhighlights($id)]} {
5042+
# this sets fhighlights($id) to -1
50505043
askfilehighlight $l $id
50515044
}
5052-
if {$fhighlights($l) > 0} {
5045+
if {$fhighlights($id) > 0} {
50535046
set found $domore
50545047
break
50555048
}
5056-
if {$fhighlights($l) < 0} {
5049+
if {$fhighlights($id) < 0} {
50575050
if {$domore} {
50585051
set domore 0
50595052
set findcurline [expr {$l - $find_dirn}]

0 commit comments

Comments
 (0)