gitk: Recompute ancestor/descendent heads/tags when rereading refs
We weren't updating the desc_heads, desc_tags and anc_tags arrays when rereading the set of heads/tags/etc. The tricky thing to get right here is restarting the computation correctly when we are only half-way through it. Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
parent
e1a7c81f6a
commit
cec7bece83
90
gitk
90
gitk
@ -4932,7 +4932,7 @@ proc domktag {} {
|
||||
|
||||
proc redrawtags {id} {
|
||||
global canv linehtag commitrow idpos selectedline curview
|
||||
global mainfont
|
||||
global mainfont canvxmax
|
||||
|
||||
if {![info exists commitrow($curview,$id)]} return
|
||||
drawcmitrow $commitrow($curview,$id)
|
||||
@ -5020,8 +5020,9 @@ proc wrcomcan {} {
|
||||
|
||||
# Stuff for finding nearby tags
|
||||
proc getallcommits {} {
|
||||
global allcstart allcommits allcfd
|
||||
global allcstart allcommits allcfd allids
|
||||
|
||||
set allids {}
|
||||
set fd [open [concat | git rev-list --all --topo-order --parents] r]
|
||||
set allcfd $fd
|
||||
fconfigure $fd -blocking 0
|
||||
@ -5105,27 +5106,12 @@ proc combine_atags {l1 l2} {
|
||||
return $res
|
||||
}
|
||||
|
||||
proc getallclines {fd} {
|
||||
global allparents allchildren allcommits allcstart
|
||||
global desc_tags anc_tags idtags alldtags tagisdesc allids
|
||||
global desc_heads idheads
|
||||
proc forward_pass {id children} {
|
||||
global idtags desc_tags idheads desc_heads alldtags tagisdesc
|
||||
|
||||
while {[gets $fd line] >= 0} {
|
||||
set id [lindex $line 0]
|
||||
lappend allids $id
|
||||
set olds [lrange $line 1 end]
|
||||
set allparents($id) $olds
|
||||
if {![info exists allchildren($id)]} {
|
||||
set allchildren($id) {}
|
||||
}
|
||||
foreach p $olds {
|
||||
lappend allchildren($p) $id
|
||||
}
|
||||
# compute nearest tagged descendents as we go
|
||||
# also compute descendent heads
|
||||
set dtags {}
|
||||
set dheads {}
|
||||
foreach child $allchildren($id) {
|
||||
foreach child $children {
|
||||
if {[info exists idtags($child)]} {
|
||||
set ctags [list $child]
|
||||
} else {
|
||||
@ -5160,6 +5146,27 @@ proc getallclines {fd} {
|
||||
lappend dheads $id
|
||||
}
|
||||
set desc_heads($id) $dheads
|
||||
}
|
||||
|
||||
proc getallclines {fd} {
|
||||
global allparents allchildren allcommits allcstart
|
||||
global desc_tags anc_tags idtags tagisdesc allids
|
||||
global desc_heads idheads travindex
|
||||
|
||||
while {[gets $fd line] >= 0} {
|
||||
set id [lindex $line 0]
|
||||
lappend allids $id
|
||||
set olds [lrange $line 1 end]
|
||||
set allparents($id) $olds
|
||||
if {![info exists allchildren($id)]} {
|
||||
set allchildren($id) {}
|
||||
}
|
||||
foreach p $olds {
|
||||
lappend allchildren($p) $id
|
||||
}
|
||||
# compute nearest tagged descendents as we go
|
||||
# also compute descendent heads
|
||||
forward_pass $id $allchildren($id)
|
||||
if {[clock clicks -milliseconds] - $allcstart >= 50} {
|
||||
fileevent $fd readable {}
|
||||
after idle restartgetall $fd
|
||||
@ -5167,7 +5174,9 @@ proc getallclines {fd} {
|
||||
}
|
||||
}
|
||||
if {[eof $fd]} {
|
||||
after idle restartatags [llength $allids]
|
||||
set travindex [llength $allids]
|
||||
set allcommits "traversing"
|
||||
after idle restartatags
|
||||
if {[catch {close $fd} err]} {
|
||||
error_popup "Error reading full commit graph: $err.\n\
|
||||
Results may be incomplete."
|
||||
@ -5176,10 +5185,11 @@ proc getallclines {fd} {
|
||||
}
|
||||
|
||||
# walk backward through the tree and compute nearest tagged ancestors
|
||||
proc restartatags {i} {
|
||||
global allids allparents idtags anc_tags t0
|
||||
proc restartatags {} {
|
||||
global allids allparents idtags anc_tags travindex
|
||||
|
||||
set t0 [clock clicks -milliseconds]
|
||||
set i $travindex
|
||||
while {[incr i -1] >= 0} {
|
||||
set id [lindex $allids $i]
|
||||
set atags {}
|
||||
@ -5197,17 +5207,41 @@ proc restartatags {i} {
|
||||
}
|
||||
set anc_tags($id) $atags
|
||||
if {[clock clicks -milliseconds] - $t0 >= 50} {
|
||||
after idle restartatags $i
|
||||
set travindex $i
|
||||
after idle restartatags
|
||||
return
|
||||
}
|
||||
}
|
||||
set allcommits "done"
|
||||
set travindex 0
|
||||
notbusy allcommits
|
||||
dispneartags
|
||||
}
|
||||
|
||||
proc changedrefs {} {
|
||||
global desc_heads desc_tags anc_tags allcommits allids
|
||||
global allchildren allparents idtags travindex
|
||||
|
||||
if {![info exists allcommits]} return
|
||||
catch {unset desc_heads}
|
||||
catch {unset desc_tags}
|
||||
catch {unset anc_tags}
|
||||
catch {unset alldtags}
|
||||
catch {unset tagisdesc}
|
||||
foreach id $allids {
|
||||
forward_pass $id $allchildren($id)
|
||||
}
|
||||
if {$allcommits ne "reading"} {
|
||||
set travindex [llength $allids]
|
||||
if {$allcommits ne "traversing"} {
|
||||
set allcommits "traversing"
|
||||
after idle restartatags
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc rereadrefs {} {
|
||||
global idtags idheads idotherrefs
|
||||
global idtags idheads idotherrefs mainhead
|
||||
|
||||
set refids [concat [array names idtags] \
|
||||
[array names idheads] [array names idotherrefs]]
|
||||
@ -5216,12 +5250,16 @@ proc rereadrefs {} {
|
||||
set ref($id) [listrefs $id]
|
||||
}
|
||||
}
|
||||
set oldmainhead $mainhead
|
||||
readrefs
|
||||
changedrefs
|
||||
set refids [lsort -unique [concat $refids [array names idtags] \
|
||||
[array names idheads] [array names idotherrefs]]]
|
||||
foreach id $refids {
|
||||
set v [listrefs $id]
|
||||
if {![info exists ref($id)] || $ref($id) != $v} {
|
||||
if {![info exists ref($id)] || $ref($id) != $v ||
|
||||
($id eq $oldmainhead && $id ne $mainhead) ||
|
||||
($id eq $mainhead && $id ne $oldmainhead)} {
|
||||
redrawtags $id
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user