@matheusbsbs / matheus-bagliano / commits / c9cfdc9601
Fork 0

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>

Paul Mackerras committed Mar 4, 2008 at 21:32 UTC c9cfdc9601668841a5909facd43aed72e7a8dee5
1 file changed +23 -22
gitk
+23 -22
@@ -609,9 +609,7 @@ proc insertfakerow {id p} {
609 set numcommits [incr commitidx($v)]
610 # note we deliberately don't update varcstart($v) even if $i == 0
611 set varccommits($v,$a) [linsert $varccommits($v,$a) $i $id]
612 - if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] < 0} {
613 - modify_arc $v $a $i
614 - }
612 + modify_arc $v $a $i
613 if {[info exists targetid]} {
614 if {![comes_before $targetid $p]} {
615 incr targetrow
@@ -648,9 +646,7 @@ proc removefakerow {id} {
646 if {$j >= 0} {
647 set children($v,$p) [lreplace $children($v,$p) $j $j]
648 }
651 - if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] < 0} {
652 - modify_arc $v $a $i
653 - }
649 + modify_arc $v $a $i
650 if {[info exist currentid] && $id eq $currentid} {
651 unset currentid
652 unset selectedline
@@ -693,9 +689,19 @@ proc vtokcmp {v a b} {
689 [lindex $varctok($v) $varcid($v,$b)]]
690 }
691
692 +# This assumes that if lim is not given, the caller has checked that
693 +# arc a's token is less than $vtokmod($v)
694 proc modify_arc {v a {lim {}}} {
695 global varctok vtokmod varcmod varcrow vupptr curview vrowmod varccommits
696
697 + if {$lim ne {}} {
698 + set c [string compare [lindex $varctok($v) $a] $vtokmod($v)]
699 + if {$c > 0} return
700 + if {$c == 0} {
701 + set r [lindex $varcrow($v) $a]
702 + if {$r ne {} && $vrowmod($v) <= $r + $lim} return
703 + }
704 + }
705 set vtokmod($v) [lindex $varctok($v) $a]
706 set varcmod($v) $a
707 if {$v == $curview} {
@@ -721,6 +727,14 @@ proc update_arcrows {v} {
727 global vupptr vdownptr vleftptr varctok
728 global displayorder parentlist curview cached_commitrow
729
730 + if {$vrowmod($v) == $commitidx($v)} return
731 + if {$v == $curview} {
732 + if {[llength $displayorder] > $vrowmod($v)} {
733 + set displayorder [lrange $displayorder 0 [expr {$vrowmod($v) - 1}]]
734 + set parentlist [lrange $parentlist 0 [expr {$vrowmod($v) - 1}]]
735 + }
736 + catch {unset cached_commitrow}
737 + }
738 set narctot [expr {[llength $varctok($v)] - 1}]
739 set a $varcmod($v)
740 while {$a != 0 && [lindex $varcix($v) $a] eq {}} {
@@ -739,23 +753,12 @@ proc update_arcrows {v} {
753 set row 0
754 } else {
755 set arcn [lindex $varcix($v) $a]
742 - # see if a is the last arc; if so, nothing to do
743 - if {$arcn == $narctot - 1} {
744 - return
745 - }
756 if {[llength $vrownum($v)] > $arcn + 1} {
757 set vrownum($v) [lrange $vrownum($v) 0 $arcn]
758 set varcorder($v) [lrange $varcorder($v) 0 $arcn]
759 }
760 set row [lindex $varcrow($v) $a]
761 }
752 - if {$v == $curview} {
753 - if {[llength $displayorder] > $vrowmod($v)} {
754 - set displayorder [lrange $displayorder 0 [expr {$vrowmod($v) - 1}]]
755 - set parentlist [lrange $parentlist 0 [expr {$vrowmod($v) - 1}]]
756 - }
757 - catch {unset cached_commitrow}
758 - }
762 while {1} {
763 set p $a
764 incr row [llength $varccommits($v,$a)]
@@ -969,11 +972,9 @@ proc rewrite_commit {v id rwid} {
972 # fix the graph after joining $id to $rwid
973 set a $varcid($v,$ch)
974 fix_reversal $rwid $a $v
972 - if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] < 0} {
973 - # parentlist is wrong for the last element of arc $a
974 - # even if displayorder is right, hence the 3rd arg here
975 - modify_arc $v $a [expr {[llength $varccommits($v,$a)] - 1}]
976 - }
975 + # parentlist is wrong for the last element of arc $a
976 + # even if displayorder is right, hence the 3rd arg here
977 + modify_arc $v $a [expr {[llength $varccommits($v,$a)] - 1}]
978 }
979 }
980