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:
90
gitk
90
gitk
@ -4932,7 +4932,7 @@ proc domktag {} {
|
|||||||
|
|
||||||
proc redrawtags {id} {
|
proc redrawtags {id} {
|
||||||
global canv linehtag commitrow idpos selectedline curview
|
global canv linehtag commitrow idpos selectedline curview
|
||||||
global mainfont
|
global mainfont canvxmax
|
||||||
|
|
||||||
if {![info exists commitrow($curview,$id)]} return
|
if {![info exists commitrow($curview,$id)]} return
|
||||||
drawcmitrow $commitrow($curview,$id)
|
drawcmitrow $commitrow($curview,$id)
|
||||||
@ -5020,8 +5020,9 @@ proc wrcomcan {} {
|
|||||||
|
|
||||||
# Stuff for finding nearby tags
|
# Stuff for finding nearby tags
|
||||||
proc getallcommits {} {
|
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 fd [open [concat | git rev-list --all --topo-order --parents] r]
|
||||||
set allcfd $fd
|
set allcfd $fd
|
||||||
fconfigure $fd -blocking 0
|
fconfigure $fd -blocking 0
|
||||||
@ -5105,27 +5106,12 @@ proc combine_atags {l1 l2} {
|
|||||||
return $res
|
return $res
|
||||||
}
|
}
|
||||||
|
|
||||||
proc getallclines {fd} {
|
proc forward_pass {id children} {
|
||||||
global allparents allchildren allcommits allcstart
|
global idtags desc_tags idheads desc_heads alldtags tagisdesc
|
||||||
global desc_tags anc_tags idtags alldtags tagisdesc allids
|
|
||||||
global desc_heads idheads
|
|
||||||
|
|
||||||
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 dtags {}
|
||||||
set dheads {}
|
set dheads {}
|
||||||
foreach child $allchildren($id) {
|
foreach child $children {
|
||||||
if {[info exists idtags($child)]} {
|
if {[info exists idtags($child)]} {
|
||||||
set ctags [list $child]
|
set ctags [list $child]
|
||||||
} else {
|
} else {
|
||||||
@ -5160,6 +5146,27 @@ proc getallclines {fd} {
|
|||||||
lappend dheads $id
|
lappend dheads $id
|
||||||
}
|
}
|
||||||
set desc_heads($id) $dheads
|
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} {
|
if {[clock clicks -milliseconds] - $allcstart >= 50} {
|
||||||
fileevent $fd readable {}
|
fileevent $fd readable {}
|
||||||
after idle restartgetall $fd
|
after idle restartgetall $fd
|
||||||
@ -5167,7 +5174,9 @@ proc getallclines {fd} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if {[eof $fd]} {
|
if {[eof $fd]} {
|
||||||
after idle restartatags [llength $allids]
|
set travindex [llength $allids]
|
||||||
|
set allcommits "traversing"
|
||||||
|
after idle restartatags
|
||||||
if {[catch {close $fd} err]} {
|
if {[catch {close $fd} err]} {
|
||||||
error_popup "Error reading full commit graph: $err.\n\
|
error_popup "Error reading full commit graph: $err.\n\
|
||||||
Results may be incomplete."
|
Results may be incomplete."
|
||||||
@ -5176,10 +5185,11 @@ proc getallclines {fd} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# walk backward through the tree and compute nearest tagged ancestors
|
# walk backward through the tree and compute nearest tagged ancestors
|
||||||
proc restartatags {i} {
|
proc restartatags {} {
|
||||||
global allids allparents idtags anc_tags t0
|
global allids allparents idtags anc_tags travindex
|
||||||
|
|
||||||
set t0 [clock clicks -milliseconds]
|
set t0 [clock clicks -milliseconds]
|
||||||
|
set i $travindex
|
||||||
while {[incr i -1] >= 0} {
|
while {[incr i -1] >= 0} {
|
||||||
set id [lindex $allids $i]
|
set id [lindex $allids $i]
|
||||||
set atags {}
|
set atags {}
|
||||||
@ -5197,17 +5207,41 @@ proc restartatags {i} {
|
|||||||
}
|
}
|
||||||
set anc_tags($id) $atags
|
set anc_tags($id) $atags
|
||||||
if {[clock clicks -milliseconds] - $t0 >= 50} {
|
if {[clock clicks -milliseconds] - $t0 >= 50} {
|
||||||
after idle restartatags $i
|
set travindex $i
|
||||||
|
after idle restartatags
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set allcommits "done"
|
set allcommits "done"
|
||||||
|
set travindex 0
|
||||||
notbusy allcommits
|
notbusy allcommits
|
||||||
dispneartags
|
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 {} {
|
proc rereadrefs {} {
|
||||||
global idtags idheads idotherrefs
|
global idtags idheads idotherrefs mainhead
|
||||||
|
|
||||||
set refids [concat [array names idtags] \
|
set refids [concat [array names idtags] \
|
||||||
[array names idheads] [array names idotherrefs]]
|
[array names idheads] [array names idotherrefs]]
|
||||||
@ -5216,12 +5250,16 @@ proc rereadrefs {} {
|
|||||||
set ref($id) [listrefs $id]
|
set ref($id) [listrefs $id]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
set oldmainhead $mainhead
|
||||||
readrefs
|
readrefs
|
||||||
|
changedrefs
|
||||||
set refids [lsort -unique [concat $refids [array names idtags] \
|
set refids [lsort -unique [concat $refids [array names idtags] \
|
||||||
[array names idheads] [array names idotherrefs]]]
|
[array names idheads] [array names idotherrefs]]]
|
||||||
foreach id $refids {
|
foreach id $refids {
|
||||||
set v [listrefs $id]
|
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
|
redrawtags $id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user