зеркало из https://github.com/microsoft/git.git
gitk: Store ids in rowrangelist and idrowranges rather than row numbers
This removes the need for insertrow to go through rowrangelist and idrowranges and adjust a lot of entries. The first entry for a given id is now the row number of the first child, not that row number + 1, and rowranges compensates for that so its callers didn't have to change. This adds a ranges argument to drawlineseg so that we can avoid calling rowranges a second time inside drawlineseg (all its callers already called rowranges). Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
Родитель
0060946397
Коммит
66e46f37de
76
gitk
76
gitk
|
@ -2472,7 +2472,7 @@ proc sanity {row {full 0}} {
|
||||||
}
|
}
|
||||||
|
|
||||||
proc makeuparrow {oid x y z} {
|
proc makeuparrow {oid x y z} {
|
||||||
global rowidlist rowoffsets uparrowlen idrowranges
|
global rowidlist rowoffsets uparrowlen idrowranges displayorder
|
||||||
|
|
||||||
for {set i 1} {$i < $uparrowlen && $y > 1} {incr i} {
|
for {set i 1} {$i < $uparrowlen && $y > 1} {incr i} {
|
||||||
incr y -1
|
incr y -1
|
||||||
|
@ -2495,7 +2495,7 @@ proc makeuparrow {oid x y z} {
|
||||||
}
|
}
|
||||||
set tmp [lreplace [lindex $rowoffsets $y] $x $x {}]
|
set tmp [lreplace [lindex $rowoffsets $y] $x $x {}]
|
||||||
lset rowoffsets $y [incrange $tmp [expr {$x+1}] -1]
|
lset rowoffsets $y [incrange $tmp [expr {$x+1}] -1]
|
||||||
lappend idrowranges($oid) $y
|
lappend idrowranges($oid) [lindex $displayorder $y]
|
||||||
}
|
}
|
||||||
|
|
||||||
proc initlayout {} {
|
proc initlayout {} {
|
||||||
|
@ -2609,7 +2609,7 @@ proc layoutmore {tmax allread} {
|
||||||
|
|
||||||
proc showstuff {canshow} {
|
proc showstuff {canshow} {
|
||||||
global numcommits commitrow pending_select selectedline
|
global numcommits commitrow pending_select selectedline
|
||||||
global linesegends idrowranges idrangedrawn curview
|
global linesegends idrangedrawn curview
|
||||||
global displayorder selectfirst
|
global displayorder selectfirst
|
||||||
|
|
||||||
if {$numcommits == 0} {
|
if {$numcommits == 0} {
|
||||||
|
@ -2627,11 +2627,12 @@ proc showstuff {canshow} {
|
||||||
for {set r $row} {$r < $canshow} {incr r} {
|
for {set r $row} {$r < $canshow} {incr r} {
|
||||||
foreach id [lindex $linesegends [expr {$r+1}]] {
|
foreach id [lindex $linesegends [expr {$r+1}]] {
|
||||||
set i -1
|
set i -1
|
||||||
foreach {s e} [rowranges $id] {
|
set ranges [rowranges $id]
|
||||||
|
foreach {s e} $ranges {
|
||||||
incr i
|
incr i
|
||||||
if {$e ne {} && $e < $numcommits && $s <= $r1 && $e >= $r0
|
if {$e ne {} && $e < $numcommits && $s <= $r1 && $e >= $r0
|
||||||
&& ![info exists idrangedrawn($id,$i)]} {
|
&& ![info exists idrangedrawn($id,$i)]} {
|
||||||
drawlineseg $id $i
|
drawlineseg $id $i $ranges
|
||||||
set idrangedrawn($id,$i) 1
|
set idrangedrawn($id,$i) 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2698,7 +2699,7 @@ proc layoutrows {row endrow last} {
|
||||||
set idinlist($i) 0
|
set idinlist($i) 0
|
||||||
set rm1 [expr {$row - 1}]
|
set rm1 [expr {$row - 1}]
|
||||||
lappend lse $i
|
lappend lse $i
|
||||||
lappend idrowranges($i) $rm1
|
lappend idrowranges($i) [lindex $displayorder $rm1]
|
||||||
if {[incr nev -1] <= 0} break
|
if {[incr nev -1] <= 0} break
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -2730,7 +2731,7 @@ proc layoutrows {row endrow last} {
|
||||||
set ranges {}
|
set ranges {}
|
||||||
if {[info exists idrowranges($id)]} {
|
if {[info exists idrowranges($id)]} {
|
||||||
set ranges $idrowranges($id)
|
set ranges $idrowranges($id)
|
||||||
lappend ranges $row
|
lappend ranges $id
|
||||||
unset idrowranges($id)
|
unset idrowranges($id)
|
||||||
}
|
}
|
||||||
lappend rowrangelist $ranges
|
lappend rowrangelist $ranges
|
||||||
|
@ -2755,7 +2756,7 @@ proc layoutrows {row endrow last} {
|
||||||
}
|
}
|
||||||
foreach i $newolds {
|
foreach i $newolds {
|
||||||
set idinlist($i) 1
|
set idinlist($i) 1
|
||||||
set idrowranges($i) $row
|
set idrowranges($i) $id
|
||||||
}
|
}
|
||||||
incr col $l
|
incr col $l
|
||||||
foreach oid $oldolds {
|
foreach oid $oldolds {
|
||||||
|
@ -2993,16 +2994,22 @@ proc rowranges {id} {
|
||||||
} elseif {[info exists idrowranges($id)]} {
|
} elseif {[info exists idrowranges($id)]} {
|
||||||
set ranges $idrowranges($id)
|
set ranges $idrowranges($id)
|
||||||
}
|
}
|
||||||
return $ranges
|
set linenos {}
|
||||||
|
foreach rid $ranges {
|
||||||
|
lappend linenos $commitrow($curview,$rid)
|
||||||
|
}
|
||||||
|
if {$linenos ne {}} {
|
||||||
|
lset linenos 0 [expr {[lindex $linenos 0] + 1}]
|
||||||
|
}
|
||||||
|
return $linenos
|
||||||
}
|
}
|
||||||
|
|
||||||
proc drawlineseg {id i} {
|
proc drawlineseg {id i ranges} {
|
||||||
global rowoffsets rowidlist
|
global rowoffsets rowidlist
|
||||||
global displayorder
|
global displayorder
|
||||||
global canv colormap linespc
|
global canv colormap linespc
|
||||||
global numcommits commitrow curview
|
global numcommits commitrow curview
|
||||||
|
|
||||||
set ranges [rowranges $id]
|
|
||||||
set downarrow 1
|
set downarrow 1
|
||||||
if {[info exists commitrow($curview,$id)]
|
if {[info exists commitrow($curview,$id)]
|
||||||
&& $commitrow($curview,$id) < $numcommits} {
|
&& $commitrow($curview,$id) < $numcommits} {
|
||||||
|
@ -3132,10 +3139,11 @@ proc drawlines {id} {
|
||||||
global children iddrawn commitrow rowidlist curview
|
global children iddrawn commitrow rowidlist curview
|
||||||
|
|
||||||
$canv delete lines.$id
|
$canv delete lines.$id
|
||||||
set nr [expr {[llength [rowranges $id]] / 2}]
|
set ranges [rowranges $id]
|
||||||
|
set nr [expr {[llength $ranges] / 2}]
|
||||||
for {set i 0} {$i < $nr} {incr i} {
|
for {set i 0} {$i < $nr} {incr i} {
|
||||||
if {[info exists idrangedrawn($id,$i)]} {
|
if {[info exists idrangedrawn($id,$i)]} {
|
||||||
drawlineseg $id $i
|
drawlineseg $id $i $ranges
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach child $children($curview,$id) {
|
foreach child $children($curview,$id) {
|
||||||
|
@ -3216,13 +3224,14 @@ proc drawcmitrow {row} {
|
||||||
foreach id [lindex $rowidlist $row] {
|
foreach id [lindex $rowidlist $row] {
|
||||||
if {$id eq {}} continue
|
if {$id eq {}} continue
|
||||||
set i -1
|
set i -1
|
||||||
foreach {s e} [rowranges $id] {
|
set ranges [rowranges $id]
|
||||||
|
foreach {s e} $ranges {
|
||||||
incr i
|
incr i
|
||||||
if {$row < $s} continue
|
if {$row < $s} continue
|
||||||
if {$e eq {}} break
|
if {$e eq {}} break
|
||||||
if {$row <= $e} {
|
if {$row <= $e} {
|
||||||
if {$e < $numcommits && ![info exists idrangedrawn($id,$i)]} {
|
if {$e < $numcommits && ![info exists idrangedrawn($id,$i)]} {
|
||||||
drawlineseg $id $i
|
drawlineseg $id $i $ranges
|
||||||
set idrangedrawn($id,$i) 1
|
set idrangedrawn($id,$i) 1
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
@ -3528,7 +3537,7 @@ proc show_status {msg} {
|
||||||
proc insertrow {row newcmit} {
|
proc insertrow {row newcmit} {
|
||||||
global displayorder parentlist childlist commitlisted
|
global displayorder parentlist childlist commitlisted
|
||||||
global commitrow curview rowidlist rowoffsets numcommits
|
global commitrow curview rowidlist rowoffsets numcommits
|
||||||
global rowrangelist idrowranges rowlaidout rowoptim numcommits
|
global rowrangelist rowlaidout rowoptim numcommits
|
||||||
global linesegends selectedline
|
global linesegends selectedline
|
||||||
|
|
||||||
if {$row >= $numcommits} {
|
if {$row >= $numcommits} {
|
||||||
|
@ -3572,45 +3581,16 @@ proc insertrow {row newcmit} {
|
||||||
set rowoffsets [linsert $rowoffsets [expr {$row+1}] $newoffs]
|
set rowoffsets [linsert $rowoffsets [expr {$row+1}] $newoffs]
|
||||||
|
|
||||||
set rowrangelist [linsert $rowrangelist $row {}]
|
set rowrangelist [linsert $rowrangelist $row {}]
|
||||||
set l [llength $rowrangelist]
|
|
||||||
for {set r 0} {$r < $l} {incr r} {
|
|
||||||
set ranges [lindex $rowrangelist $r]
|
|
||||||
if {$ranges ne {} && [lindex $ranges end] >= $row} {
|
|
||||||
set newranges {}
|
|
||||||
foreach x $ranges {
|
|
||||||
if {$x >= $row} {
|
|
||||||
lappend newranges [expr {$x + 1}]
|
|
||||||
} else {
|
|
||||||
lappend newranges $x
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lset rowrangelist $r $newranges
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if {[llength $kids] > 1} {
|
if {[llength $kids] > 1} {
|
||||||
set rp1 [expr {$row + 1}]
|
set rp1 [expr {$row + 1}]
|
||||||
set ranges [lindex $rowrangelist $rp1]
|
set ranges [lindex $rowrangelist $rp1]
|
||||||
if {$ranges eq {}} {
|
if {$ranges eq {}} {
|
||||||
set ranges [list $row $rp1]
|
set ranges [list $newcmit $p]
|
||||||
} elseif {[lindex $ranges end-1] == $rp1} {
|
} elseif {[lindex $ranges end-1] eq $p} {
|
||||||
lset ranges end-1 $row
|
lset ranges end-1 $newcmit
|
||||||
}
|
}
|
||||||
lset rowrangelist $rp1 $ranges
|
lset rowrangelist $rp1 $ranges
|
||||||
}
|
}
|
||||||
foreach id [array names idrowranges] {
|
|
||||||
set ranges $idrowranges($id)
|
|
||||||
if {$ranges ne {} && [lindex $ranges end] >= $row} {
|
|
||||||
set newranges {}
|
|
||||||
foreach x $ranges {
|
|
||||||
if {$x >= $row} {
|
|
||||||
lappend newranges [expr {$x + 1}]
|
|
||||||
} else {
|
|
||||||
lappend newranges $x
|
|
||||||
}
|
|
||||||
}
|
|
||||||
set idrowranges($id) $newranges
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
set linesegends [linsert $linesegends $row {}]
|
set linesegends [linsert $linesegends $row {}]
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче