gitk: Get rid of the rowchk array
Instead, when looking for lines that should be terminated with a down arrow, we look at the parents of the commit $downarrowlen + 1 rows before. This gets rid of one more place where we are assuming that all the rows are laid out in order from top to bottom. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Aug 24, 2007 at 22:16 UTC
8f0bc7e95e41673a853a53e17708c6f4f46e6420
1 file changed
+31
-24
gitk
+31
-24
@@ -1951,7 +1951,7 @@ proc showview {n} {
1951
global curview viewdata viewfiles
1952
global displayorder parentlist rowidlist
1953
global colormap rowtextx commitrow nextcolor canvxmax
1954
- global numcommits commitlisted rowchk
1954
+ global numcommits commitlisted
1955
global selectedline currentid canv canvy0
1956
global treediffs
1957
global pending_select phase
@@ -2027,7 +2027,6 @@ proc showview {n} {
2027
set rowlaidout [lindex $v 2]
2028
set rowoptim [lindex $v 3]
2029
set numcommits [lindex $v 4]
2030
- catch {unset rowchk}
2030
}
2031
2032
catch {unset colormap}
@@ -2704,7 +2703,6 @@ proc makeuparrow {oid y x} {
2703
proc initlayout {} {
2704
global rowidlist displayorder commitlisted
2705
global rowlaidout rowoptim
2707
- global rowchk
2706
global numcommits canvxmax canv
2707
global nextcolor
2708
global parentlist
@@ -2717,7 +2715,6 @@ proc initlayout {} {
2715
set parentlist {}
2716
set nextcolor 0
2717
set rowidlist {{}}
2720
- catch {unset rowchk}
2718
set rowlaidout 0
2719
set rowoptim 0
2720
set canvxmax [$canv cget -width]
@@ -2964,29 +2961,43 @@ proc readdifffiles {fd serial} {
2961
return 0
2962
}
2963
2964
+proc nextuse {id row} {
2965
+ global commitrow curview children
2966
+
2967
+ if {[info exists children($curview,$id)]} {
2968
+ foreach kid $children($curview,$id) {
2969
+ if {[info exists commitrow($curview,$kid)] &&
2970
+ $commitrow($curview,$kid) > $row} {
2971
+ return $commitrow($curview,$kid)
2972
+ }
2973
+ }
2974
+ }
2975
+ if {[info exists commitrow($curview,$id)]} {
2976
+ return $commitrow($curview,$id)
2977
+ }
2978
+ return -1
2979
+}
2980
+
2981
proc layoutrows {row endrow last} {
2982
global rowidlist displayorder
2983
global uparrowlen downarrowlen maxwidth mingaplen
2984
global children parentlist
2985
global commitidx curview
2972
- global rowchk
2986
2987
set idlist [lindex $rowidlist $row]
2988
+ if {!$last && $endrow + $uparrowlen + $mingaplen > $commitidx($curview)} {
2989
+ set endrow [expr {$commitidx($curview) - $uparrowlen - $mingaplen}]
2990
+ }
2991
while {$row < $endrow} {
2992
set id [lindex $displayorder $row]
2977
- if {1} {
2978
- if {!$last &&
2979
- $row + $uparrowlen + $mingaplen >= $commitidx($curview)} break
2980
- for {set x [llength $idlist]} {[incr x -1] >= 0} {} {
2981
- set i [lindex $idlist $x]
2982
- if {![info exists rowchk($i)] || $row >= $rowchk($i)} {
2983
- set r [usedinrange $i [expr {$row - $downarrowlen}] \
2984
- [expr {$row + $uparrowlen + $mingaplen}]]
2985
- if {$r == 0} {
2986
- set idlist [lreplace $idlist $x $x]
2987
- continue
2988
- }
2989
- set rowchk($i) [expr {$row + $r}]
2993
+ if {$row > $downarrowlen} {
2994
+ set termrow [expr {$row - $downarrowlen - 1}]
2995
+ foreach p [lindex $parentlist $termrow] {
2996
+ set i [lsearch -exact $idlist $p]
2997
+ if {$i < 0} continue
2998
+ set nr [nextuse $p $termrow]
2999
+ if {$nr < 0 || $nr >= $row + $mingaplen + $uparrowlen} {
3000
+ set idlist [lreplace $idlist $i $i]
3001
}
3002
}
3003
lset rowidlist $row $idlist
@@ -3958,7 +3969,7 @@ proc insertrow {row newcmit} {
3969
global displayorder parentlist commitlisted children
3970
global commitrow curview rowidlist numcommits
3971
global rowlaidout rowoptim numcommits
3961
- global selectedline rowchk commitidx
3972
+ global selectedline commitidx
3973
3974
if {$row >= $numcommits} {
3975
puts "oops, inserting new row $row but only have $numcommits rows"
@@ -3989,8 +4000,6 @@ proc insertrow {row newcmit} {
4000
}
4001
set rowidlist [linsert $rowidlist $row $idlist]
4002
3992
- catch {unset rowchk}
3993
-
4003
incr rowlaidout
4004
incr rowoptim
4005
incr numcommits
@@ -4006,7 +4015,7 @@ proc removerow {row} {
4015
global displayorder parentlist commitlisted children
4016
global commitrow curview rowidlist numcommits
4017
global rowlaidout rowoptim numcommits
4009
- global linesegends selectedline rowchk commitidx
4018
+ global linesegends selectedline commitidx
4019
4020
if {$row >= $numcommits} {
4021
puts "oops, removing row $row but only have $numcommits rows"
@@ -4033,8 +4042,6 @@ proc removerow {row} {
4042
4043
set rowidlist [lreplace $rowidlist $row $row]
4044
4036
- catch {unset rowchk}
4037
-
4045
incr rowlaidout -1
4046
incr rowoptim -1
4047
incr numcommits -1