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

gitk: Fix bug causing nearby tags/heads to sometimes not be displayed

When we compute descendent heads and descendent/ancestor tags, we cache the results. We need to be careful to invalidate the cache when we add stuff to the graph. Also make sure that when we cache descendent heads for a node we only cache the heads that are actually descendents of that node. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Jun 18, 2007 at 22:39 UTC f3326b66bf8d77c19b5ca7ad70e536251c81cccb
1 file changed +11 -3
gitk
+11 -3
@@ -5950,7 +5950,7 @@ proc regetallcommits {} {
5950 # coming from descendents, and "outgoing" means going towards ancestors.
5951
5952 proc getallclines {fd} {
5953 - global allids allparents allchildren idtags nextarc nbmp
5953 + global allids allparents allchildren idtags idheads nextarc nbmp
5954 global arcnos arcids arctags arcout arcend arcstart archeads growing
5955 global seeds allcommits
5956
@@ -6023,6 +6023,12 @@ proc getallclines {fd} {
6023 }
6024 set arcout($id) $ao
6025 }
6026 + if {$nid > 0} {
6027 + global cached_dheads cached_dtags cached_atags
6028 + catch {unset cached_dheads}
6029 + catch {unset cached_dtags}
6030 + catch {unset cached_atags}
6031 + }
6032 if {![eof $fd]} {
6033 return [expr {$nid >= 1000? 2: 1}]
6034 }
@@ -6674,7 +6680,7 @@ proc descheads {id} {
6680 if {![info exists allparents($id)]} {
6681 return {}
6682 }
6677 - set ret {}
6683 + set aret {}
6684 if {[llength $arcnos($id)] == 1 && [llength $allparents($id)] == 1} {
6685 # part-way along an arc; check it first
6686 set a [lindex $arcnos($id) 0]
@@ -6684,7 +6690,7 @@ proc descheads {id} {
6690 foreach t $archeads($a) {
6691 set j [lsearch -exact $arcids($a) $t]
6692 if {$j > $i} break
6687 - lappend $ret $t
6693 + lappend aret $t
6694 }
6695 }
6696 set id $arcstart($a)
@@ -6692,6 +6698,7 @@ proc descheads {id} {
6698 set origid $id
6699 set todo [list $id]
6700 set seen($id) 1
6701 + set ret {}
6702 for {set i 0} {$i < [llength $todo]} {incr i} {
6703 set id [lindex $todo $i]
6704 if {[info exists cached_dheads($id)]} {
@@ -6714,6 +6721,7 @@ proc descheads {id} {
6721 }
6722 set ret [lsort -unique $ret]
6723 set cached_dheads($origid) $ret
6724 + return [concat $ret $aret]
6725 }
6726
6727 proc addedtag {id} {