gitk: Fix some corner cases in computing vrowmod and displayorder
First, insertfakerow and removefakerow weren't updating vrowmod, and hence displayorder was not getting updated when it needed to, in the case where the fake row was being inserted into or removed from the last arc. The comparison of varctok vs vtokmod was moved into modify_arc for these cases (and for the call in rewrite_commit) to avoid duplicating the extra code needed. Second, the logic in update_arcrows didn't end up truncating displayorder and unsetting cached_commitrow if the first modified row was in the last arc. This fixes these problems. Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
parent
f9e0b6fb60
commit
c9cfdc9601
35
gitk
35
gitk
@ -609,9 +609,7 @@ proc insertfakerow {id p} {
|
|||||||
set numcommits [incr commitidx($v)]
|
set numcommits [incr commitidx($v)]
|
||||||
# note we deliberately don't update varcstart($v) even if $i == 0
|
# note we deliberately don't update varcstart($v) even if $i == 0
|
||||||
set varccommits($v,$a) [linsert $varccommits($v,$a) $i $id]
|
set varccommits($v,$a) [linsert $varccommits($v,$a) $i $id]
|
||||||
if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] < 0} {
|
|
||||||
modify_arc $v $a $i
|
modify_arc $v $a $i
|
||||||
}
|
|
||||||
if {[info exists targetid]} {
|
if {[info exists targetid]} {
|
||||||
if {![comes_before $targetid $p]} {
|
if {![comes_before $targetid $p]} {
|
||||||
incr targetrow
|
incr targetrow
|
||||||
@ -648,9 +646,7 @@ proc removefakerow {id} {
|
|||||||
if {$j >= 0} {
|
if {$j >= 0} {
|
||||||
set children($v,$p) [lreplace $children($v,$p) $j $j]
|
set children($v,$p) [lreplace $children($v,$p) $j $j]
|
||||||
}
|
}
|
||||||
if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] < 0} {
|
|
||||||
modify_arc $v $a $i
|
modify_arc $v $a $i
|
||||||
}
|
|
||||||
if {[info exist currentid] && $id eq $currentid} {
|
if {[info exist currentid] && $id eq $currentid} {
|
||||||
unset currentid
|
unset currentid
|
||||||
unset selectedline
|
unset selectedline
|
||||||
@ -693,9 +689,19 @@ proc vtokcmp {v a b} {
|
|||||||
[lindex $varctok($v) $varcid($v,$b)]]
|
[lindex $varctok($v) $varcid($v,$b)]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This assumes that if lim is not given, the caller has checked that
|
||||||
|
# arc a's token is less than $vtokmod($v)
|
||||||
proc modify_arc {v a {lim {}}} {
|
proc modify_arc {v a {lim {}}} {
|
||||||
global varctok vtokmod varcmod varcrow vupptr curview vrowmod varccommits
|
global varctok vtokmod varcmod varcrow vupptr curview vrowmod varccommits
|
||||||
|
|
||||||
|
if {$lim ne {}} {
|
||||||
|
set c [string compare [lindex $varctok($v) $a] $vtokmod($v)]
|
||||||
|
if {$c > 0} return
|
||||||
|
if {$c == 0} {
|
||||||
|
set r [lindex $varcrow($v) $a]
|
||||||
|
if {$r ne {} && $vrowmod($v) <= $r + $lim} return
|
||||||
|
}
|
||||||
|
}
|
||||||
set vtokmod($v) [lindex $varctok($v) $a]
|
set vtokmod($v) [lindex $varctok($v) $a]
|
||||||
set varcmod($v) $a
|
set varcmod($v) $a
|
||||||
if {$v == $curview} {
|
if {$v == $curview} {
|
||||||
@ -721,6 +727,14 @@ proc update_arcrows {v} {
|
|||||||
global vupptr vdownptr vleftptr varctok
|
global vupptr vdownptr vleftptr varctok
|
||||||
global displayorder parentlist curview cached_commitrow
|
global displayorder parentlist curview cached_commitrow
|
||||||
|
|
||||||
|
if {$vrowmod($v) == $commitidx($v)} return
|
||||||
|
if {$v == $curview} {
|
||||||
|
if {[llength $displayorder] > $vrowmod($v)} {
|
||||||
|
set displayorder [lrange $displayorder 0 [expr {$vrowmod($v) - 1}]]
|
||||||
|
set parentlist [lrange $parentlist 0 [expr {$vrowmod($v) - 1}]]
|
||||||
|
}
|
||||||
|
catch {unset cached_commitrow}
|
||||||
|
}
|
||||||
set narctot [expr {[llength $varctok($v)] - 1}]
|
set narctot [expr {[llength $varctok($v)] - 1}]
|
||||||
set a $varcmod($v)
|
set a $varcmod($v)
|
||||||
while {$a != 0 && [lindex $varcix($v) $a] eq {}} {
|
while {$a != 0 && [lindex $varcix($v) $a] eq {}} {
|
||||||
@ -739,23 +753,12 @@ proc update_arcrows {v} {
|
|||||||
set row 0
|
set row 0
|
||||||
} else {
|
} else {
|
||||||
set arcn [lindex $varcix($v) $a]
|
set arcn [lindex $varcix($v) $a]
|
||||||
# see if a is the last arc; if so, nothing to do
|
|
||||||
if {$arcn == $narctot - 1} {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if {[llength $vrownum($v)] > $arcn + 1} {
|
if {[llength $vrownum($v)] > $arcn + 1} {
|
||||||
set vrownum($v) [lrange $vrownum($v) 0 $arcn]
|
set vrownum($v) [lrange $vrownum($v) 0 $arcn]
|
||||||
set varcorder($v) [lrange $varcorder($v) 0 $arcn]
|
set varcorder($v) [lrange $varcorder($v) 0 $arcn]
|
||||||
}
|
}
|
||||||
set row [lindex $varcrow($v) $a]
|
set row [lindex $varcrow($v) $a]
|
||||||
}
|
}
|
||||||
if {$v == $curview} {
|
|
||||||
if {[llength $displayorder] > $vrowmod($v)} {
|
|
||||||
set displayorder [lrange $displayorder 0 [expr {$vrowmod($v) - 1}]]
|
|
||||||
set parentlist [lrange $parentlist 0 [expr {$vrowmod($v) - 1}]]
|
|
||||||
}
|
|
||||||
catch {unset cached_commitrow}
|
|
||||||
}
|
|
||||||
while {1} {
|
while {1} {
|
||||||
set p $a
|
set p $a
|
||||||
incr row [llength $varccommits($v,$a)]
|
incr row [llength $varccommits($v,$a)]
|
||||||
@ -969,13 +972,11 @@ proc rewrite_commit {v id rwid} {
|
|||||||
# fix the graph after joining $id to $rwid
|
# fix the graph after joining $id to $rwid
|
||||||
set a $varcid($v,$ch)
|
set a $varcid($v,$ch)
|
||||||
fix_reversal $rwid $a $v
|
fix_reversal $rwid $a $v
|
||||||
if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] < 0} {
|
|
||||||
# parentlist is wrong for the last element of arc $a
|
# parentlist is wrong for the last element of arc $a
|
||||||
# even if displayorder is right, hence the 3rd arg here
|
# even if displayorder is right, hence the 3rd arg here
|
||||||
modify_arc $v $a [expr {[llength $varccommits($v,$a)] - 1}]
|
modify_arc $v $a [expr {[llength $varccommits($v,$a)] - 1}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
proc getcommitlines {fd inst view updating} {
|
proc getcommitlines {fd inst view updating} {
|
||||||
global cmitlisted commitinterest leftover
|
global cmitlisted commitinterest leftover
|
||||||
|
Loading…
x
Reference in New Issue
Block a user