This is a small extension to the code that reads the complete commit
graph, to make it compute descendent heads as well as descendent tags.
We don't exclude descendent heads that are descendents of other
descendent heads as we do for tags, since it is useful to know all the
branches that a commit is on.
Signed-off-by: Paul Mackerras <paulus@samba.org>
allcanvs yview moveto [expr {$newtop * 1.0 / $ymax}]
}
allcanvs yview moveto [expr {$newtop * 1.0 / $ymax}]
}
-# add a list of tag names at position pos
-proc appendrefs {pos l} {
- global ctext commitrow linknum curview idtags
+# add a list of tag or branch names at position pos
+# returns the number of names inserted
+proc appendrefs {pos l var} {
+ global ctext commitrow linknum curview idtags $var
- if {[catch {$ctext index $pos}]} return
+ if {[catch {$ctext index $pos}]} {
+ return 0
+ }
set tags {}
foreach id $l {
set tags {}
foreach id $l {
- foreach tag $idtags($id) {
+ foreach tag [set $var\($id\)] {
lappend tags [concat $tag $id]
}
}
lappend tags [concat $tag $id]
}
}
}
# called when we have finished computing the nearby tags
proc dispneartags {} {
global selectedline currentid ctext anc_tags desc_tags showneartags
}
# called when we have finished computing the nearby tags
proc dispneartags {} {
global selectedline currentid ctext anc_tags desc_tags showneartags
if {![info exists selectedline] || !$showneartags} return
set id $currentid
$ctext conf -state normal
if {![info exists selectedline] || !$showneartags} return
set id $currentid
$ctext conf -state normal
+ if {[info exists desc_heads($id)]} {
+ if {[appendrefs branch $desc_heads($id) idheads] > 1} {
+ $ctext insert "branch -2c" "es"
+ }
+ }
if {[info exists anc_tags($id)]} {
if {[info exists anc_tags($id)]} {
- appendrefs follows $anc_tags($id)
+ appendrefs follows $anc_tags($id) idtags
}
if {[info exists desc_tags($id)]} {
}
if {[info exists desc_tags($id)]} {
- appendrefs precedes $desc_tags($id)
+ appendrefs precedes $desc_tags($id) idtags
}
$ctext conf -state disabled
}
}
$ctext conf -state disabled
}
global currentid sha1entry
global commentend idtags linknum
global mergemax numcommits pending_select
global currentid sha1entry
global commentend idtags linknum
global mergemax numcommits pending_select
- global cmitmode desc_tags anc_tags showneartags allcommits
+ global cmitmode desc_tags anc_tags showneartags allcommits desc_heads
catch {unset pending_select}
$canv delete hover
catch {unset pending_select}
$canv delete hover
if {![info exists allcommits]} {
getallcommits
}
if {![info exists allcommits]} {
getallcommits
}
- $ctext insert end "Follows: "
+ $ctext insert end "Branch: "
+ $ctext mark set branch "end -1c"
+ $ctext mark gravity branch left
+ if {[info exists desc_heads($id)]} {
+ if {[appendrefs branch $desc_heads($id) idheads] > 1} {
+ # turn "Branch" into "Branches"
+ $ctext insert "branch -2c" "es"
+ }
+ }
+ $ctext insert end "\nFollows: "
$ctext mark set follows "end -1c"
$ctext mark gravity follows left
if {[info exists anc_tags($id)]} {
$ctext mark set follows "end -1c"
$ctext mark gravity follows left
if {[info exists anc_tags($id)]} {
- appendrefs follows $anc_tags($id)
+ appendrefs follows $anc_tags($id) idtags
}
$ctext insert end "\nPrecedes: "
$ctext mark set precedes "end -1c"
$ctext mark gravity precedes left
if {[info exists desc_tags($id)]} {
}
$ctext insert end "\nPrecedes: "
$ctext mark set precedes "end -1c"
$ctext mark gravity precedes left
if {[info exists desc_tags($id)]} {
- appendrefs precedes $desc_tags($id)
+ appendrefs precedes $desc_tags($id) idtags
}
$ctext insert end "\n"
}
}
$ctext insert end "\n"
}
proc getallclines {fd} {
global allparents allchildren allcommits allcstart
global desc_tags anc_tags idtags alldtags tagisdesc allids
proc getallclines {fd} {
global allparents allchildren allcommits allcstart
global desc_tags anc_tags idtags alldtags tagisdesc allids
+ global desc_heads idheads
while {[gets $fd line] >= 0} {
set id [lindex $line 0]
while {[gets $fd line] >= 0} {
set id [lindex $line 0]
lappend allchildren($p) $id
}
# compute nearest tagged descendents as we go
lappend allchildren($p) $id
}
# compute nearest tagged descendents as we go
+ # also compute descendent heads
foreach child $allchildren($id) {
if {[info exists idtags($child)]} {
set ctags [list $child]
foreach child $allchildren($id) {
if {[info exists idtags($child)]} {
set ctags [list $child]
} elseif {$ctags ne $dtags} {
set dtags [combine_dtags $dtags $ctags]
}
} elseif {$ctags ne $dtags} {
set dtags [combine_dtags $dtags $ctags]
}
+ set cheads $desc_heads($child)
+ if {$dheads eq {}} {
+ set dheads $cheads
+ } elseif {$cheads ne $dheads} {
+ set dheads [lsort -unique [concat $dheads $cheads]]
+ }
}
set desc_tags($id) $dtags
if {[info exists idtags($id)]} {
}
set desc_tags($id) $dtags
if {[info exists idtags($id)]} {
set tagisdesc($tag,$id) 1
}
}
set tagisdesc($tag,$id) 1
}
}
+ if {[info exists idheads($id)]} {
+ lappend dheads $id
+ }
+ set desc_heads($id) $dheads
if {[clock clicks -milliseconds] - $allcstart >= 50} {
fileevent $fd readable {}
after idle restartgetall $fd
if {[clock clicks -milliseconds] - $allcstart >= 50} {
fileevent $fd readable {}
after idle restartgetall $fd