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>maint
							parent
							
								
									97645683bf
								
							
						
					
					
						commit
						8f0bc7e95e
					
				
							
								
								
									
										55
									
								
								gitk
								
								
								
								
							
							
						
						
									
										55
									
								
								gitk
								
								
								
								
							|  | @ -1951,7 +1951,7 @@ proc showview {n} { | ||||||
|     global curview viewdata viewfiles |     global curview viewdata viewfiles | ||||||
|     global displayorder parentlist rowidlist |     global displayorder parentlist rowidlist | ||||||
|     global colormap rowtextx commitrow nextcolor canvxmax |     global colormap rowtextx commitrow nextcolor canvxmax | ||||||
|     global numcommits commitlisted rowchk |     global numcommits commitlisted | ||||||
|     global selectedline currentid canv canvy0 |     global selectedline currentid canv canvy0 | ||||||
|     global treediffs |     global treediffs | ||||||
|     global pending_select phase |     global pending_select phase | ||||||
|  | @ -2027,7 +2027,6 @@ proc showview {n} { | ||||||
| 	set rowlaidout [lindex $v 2] | 	set rowlaidout [lindex $v 2] | ||||||
| 	set rowoptim [lindex $v 3] | 	set rowoptim [lindex $v 3] | ||||||
| 	set numcommits [lindex $v 4] | 	set numcommits [lindex $v 4] | ||||||
| 	catch {unset rowchk} |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     catch {unset colormap} |     catch {unset colormap} | ||||||
|  | @ -2704,7 +2703,6 @@ proc makeuparrow {oid y x} { | ||||||
| proc initlayout {} { | proc initlayout {} { | ||||||
|     global rowidlist displayorder commitlisted |     global rowidlist displayorder commitlisted | ||||||
|     global rowlaidout rowoptim |     global rowlaidout rowoptim | ||||||
|     global rowchk |  | ||||||
|     global numcommits canvxmax canv |     global numcommits canvxmax canv | ||||||
|     global nextcolor |     global nextcolor | ||||||
|     global parentlist |     global parentlist | ||||||
|  | @ -2717,7 +2715,6 @@ proc initlayout {} { | ||||||
|     set parentlist {} |     set parentlist {} | ||||||
|     set nextcolor 0 |     set nextcolor 0 | ||||||
|     set rowidlist {{}} |     set rowidlist {{}} | ||||||
|     catch {unset rowchk} |  | ||||||
|     set rowlaidout 0 |     set rowlaidout 0 | ||||||
|     set rowoptim 0 |     set rowoptim 0 | ||||||
|     set canvxmax [$canv cget -width] |     set canvxmax [$canv cget -width] | ||||||
|  | @ -2964,29 +2961,43 @@ proc readdifffiles {fd serial} { | ||||||
|     return 0 |     return 0 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | proc nextuse {id row} { | ||||||
|  |     global commitrow curview children | ||||||
|  |  | ||||||
|  |     if {[info exists children($curview,$id)]} { | ||||||
|  | 	foreach kid $children($curview,$id) { | ||||||
|  | 	    if {[info exists commitrow($curview,$kid)] && | ||||||
|  | 		$commitrow($curview,$kid) > $row} { | ||||||
|  | 		return $commitrow($curview,$kid) | ||||||
|  | 	    } | ||||||
|  | 	} | ||||||
|  |     } | ||||||
|  |     if {[info exists commitrow($curview,$id)]} { | ||||||
|  | 	return $commitrow($curview,$id) | ||||||
|  |     } | ||||||
|  |     return -1 | ||||||
|  | } | ||||||
|  |  | ||||||
| proc layoutrows {row endrow last} { | proc layoutrows {row endrow last} { | ||||||
|     global rowidlist displayorder |     global rowidlist displayorder | ||||||
|     global uparrowlen downarrowlen maxwidth mingaplen |     global uparrowlen downarrowlen maxwidth mingaplen | ||||||
|     global children parentlist |     global children parentlist | ||||||
|     global commitidx curview |     global commitidx curview | ||||||
|     global rowchk |  | ||||||
|  |  | ||||||
|     set idlist [lindex $rowidlist $row] |     set idlist [lindex $rowidlist $row] | ||||||
|  |     if {!$last && $endrow + $uparrowlen + $mingaplen > $commitidx($curview)} { | ||||||
|  | 	set endrow [expr {$commitidx($curview) - $uparrowlen - $mingaplen}] | ||||||
|  |     } | ||||||
|     while {$row < $endrow} { |     while {$row < $endrow} { | ||||||
| 	set id [lindex $displayorder $row] | 	set id [lindex $displayorder $row] | ||||||
| 	if {1} { | 	if {$row > $downarrowlen} { | ||||||
| 	    if {!$last && | 	    set termrow [expr {$row - $downarrowlen - 1}] | ||||||
| 		$row + $uparrowlen + $mingaplen >= $commitidx($curview)} break | 	    foreach p [lindex $parentlist $termrow] { | ||||||
| 	    for {set x [llength $idlist]} {[incr x -1] >= 0} {} { | 		set i [lsearch -exact $idlist $p] | ||||||
| 		set i [lindex $idlist $x] | 		if {$i < 0} continue | ||||||
| 		if {![info exists rowchk($i)] || $row >= $rowchk($i)} { | 		set nr [nextuse $p $termrow] | ||||||
| 		    set r [usedinrange $i [expr {$row - $downarrowlen}] \ | 		if {$nr < 0 || $nr >= $row + $mingaplen + $uparrowlen} { | ||||||
| 			       [expr {$row + $uparrowlen + $mingaplen}]] | 		    set idlist [lreplace $idlist $i $i] | ||||||
| 		    if {$r == 0} { |  | ||||||
| 			set idlist [lreplace $idlist $x $x] |  | ||||||
| 			continue |  | ||||||
| 		    } |  | ||||||
| 		    set rowchk($i) [expr {$row + $r}] |  | ||||||
| 		} | 		} | ||||||
| 	    } | 	    } | ||||||
| 	    lset rowidlist $row $idlist | 	    lset rowidlist $row $idlist | ||||||
|  | @ -3958,7 +3969,7 @@ proc insertrow {row newcmit} { | ||||||
|     global displayorder parentlist commitlisted children |     global displayorder parentlist commitlisted children | ||||||
|     global commitrow curview rowidlist numcommits |     global commitrow curview rowidlist numcommits | ||||||
|     global rowlaidout rowoptim numcommits |     global rowlaidout rowoptim numcommits | ||||||
|     global selectedline rowchk commitidx |     global selectedline commitidx | ||||||
|  |  | ||||||
|     if {$row >= $numcommits} { |     if {$row >= $numcommits} { | ||||||
| 	puts "oops, inserting new row $row but only have $numcommits rows" | 	puts "oops, inserting new row $row but only have $numcommits rows" | ||||||
|  | @ -3989,8 +4000,6 @@ proc insertrow {row newcmit} { | ||||||
|     } |     } | ||||||
|     set rowidlist [linsert $rowidlist $row $idlist] |     set rowidlist [linsert $rowidlist $row $idlist] | ||||||
|  |  | ||||||
|     catch {unset rowchk} |  | ||||||
|  |  | ||||||
|     incr rowlaidout |     incr rowlaidout | ||||||
|     incr rowoptim |     incr rowoptim | ||||||
|     incr numcommits |     incr numcommits | ||||||
|  | @ -4006,7 +4015,7 @@ proc removerow {row} { | ||||||
|     global displayorder parentlist commitlisted children |     global displayorder parentlist commitlisted children | ||||||
|     global commitrow curview rowidlist numcommits |     global commitrow curview rowidlist numcommits | ||||||
|     global rowlaidout rowoptim numcommits |     global rowlaidout rowoptim numcommits | ||||||
|     global linesegends selectedline rowchk commitidx |     global linesegends selectedline commitidx | ||||||
|  |  | ||||||
|     if {$row >= $numcommits} { |     if {$row >= $numcommits} { | ||||||
| 	puts "oops, removing row $row but only have $numcommits rows" | 	puts "oops, removing row $row but only have $numcommits rows" | ||||||
|  | @ -4033,8 +4042,6 @@ proc removerow {row} { | ||||||
|  |  | ||||||
|     set rowidlist [lreplace $rowidlist $row $row] |     set rowidlist [lreplace $rowidlist $row $row] | ||||||
|  |  | ||||||
|     catch {unset rowchk} |  | ||||||
|  |  | ||||||
|     incr rowlaidout -1 |     incr rowlaidout -1 | ||||||
|     incr rowoptim -1 |     incr rowoptim -1 | ||||||
|     incr numcommits -1 |     incr numcommits -1 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Paul Mackerras
						Paul Mackerras