gitk: Implement date mode in the new framework
This restores date mode, which lists commits by date, as far as possible given the constraint that parents come after all their children. To implement this in the new framework, we (1) only join a new commit onto an existing arc if the arc is the last arc created, (2) treat arcs as seeds unless they have a child arc that comes later, and (3) never decrease the token value for an arc. This means we get lots of "seeds", which exposed some quadratic behaviour in adding and removing seeds. To fix this, we add a vbackptr array, which points to the arc whose vleftptr entry points to us, and a vlastins array, which shows where in an arc's vdownptr/vleftptr list we last inserted a parent, which acts as a hint of a good place to start looking for where to insert a new child. This also ensures the children array elements stay in sorted order at all times. We weren't resorting the children lists when reassigning tokens in renumbervarc. Since the children lists are now always sorted, we don't have to search through all elements to find the one with the highest token; we can just use the last element. Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
parent
24f7a667e6
commit
f3ea5ede23
228
gitk
228
gitk
@ -269,19 +269,21 @@ proc strrep {n} {
|
|||||||
# --topo-order) into the order for display.
|
# --topo-order) into the order for display.
|
||||||
|
|
||||||
proc varcinit {view} {
|
proc varcinit {view} {
|
||||||
global varcstart vupptr vdownptr vleftptr varctok varcrow
|
global varcstart vupptr vdownptr vleftptr vbackptr varctok varcrow
|
||||||
global vtokmod varcmod vrowmod varcix
|
global vtokmod varcmod vrowmod varcix vlastins
|
||||||
|
|
||||||
set varcstart($view) {{}}
|
set varcstart($view) {{}}
|
||||||
set vupptr($view) {0}
|
set vupptr($view) {0}
|
||||||
set vdownptr($view) {0}
|
set vdownptr($view) {0}
|
||||||
set vleftptr($view) {0}
|
set vleftptr($view) {0}
|
||||||
|
set vbackptr($view) {0}
|
||||||
set varctok($view) {{}}
|
set varctok($view) {{}}
|
||||||
set varcrow($view) {{}}
|
set varcrow($view) {{}}
|
||||||
set vtokmod($view) {}
|
set vtokmod($view) {}
|
||||||
set varcmod($view) 0
|
set varcmod($view) 0
|
||||||
set vrowmod($view) 0
|
set vrowmod($view) 0
|
||||||
set varcix($view) {{}}
|
set varcix($view) {{}}
|
||||||
|
set vlastins($view) {0}
|
||||||
}
|
}
|
||||||
|
|
||||||
proc resetvarcs {view} {
|
proc resetvarcs {view} {
|
||||||
@ -306,13 +308,13 @@ proc resetvarcs {view} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc newvarc {view id} {
|
proc newvarc {view id} {
|
||||||
global varcid varctok parents children
|
global varcid varctok parents children datemode
|
||||||
global vupptr vdownptr vleftptr varcrow varcix varcstart
|
global vupptr vdownptr vleftptr vbackptr varcrow varcix varcstart
|
||||||
global commitdata commitinfo vseedcount varccommits
|
global commitdata commitinfo vseedcount varccommits vlastins
|
||||||
|
|
||||||
set a [llength $varctok($view)]
|
set a [llength $varctok($view)]
|
||||||
set vid $view,$id
|
set vid $view,$id
|
||||||
if {[llength $children($vid)] == 0} {
|
if {[llength $children($vid)] == 0 || $datemode} {
|
||||||
if {![info exists commitinfo($id)]} {
|
if {![info exists commitinfo($id)]} {
|
||||||
parsecommit $id $commitdata($id) 1
|
parsecommit $id $commitdata($id) 1
|
||||||
}
|
}
|
||||||
@ -326,64 +328,61 @@ proc newvarc {view id} {
|
|||||||
set c [incr vseedcount($view,$cdate)]
|
set c [incr vseedcount($view,$cdate)]
|
||||||
set cdate [expr {$cdate ^ 0xffffffff}]
|
set cdate [expr {$cdate ^ 0xffffffff}]
|
||||||
set tok "s[strrep $cdate][strrep $c]"
|
set tok "s[strrep $cdate][strrep $c]"
|
||||||
lappend vupptr($view) 0
|
|
||||||
set ka [lindex $vdownptr($view) 0]
|
|
||||||
if {$ka == 0 ||
|
|
||||||
[string compare $tok [lindex $varctok($view) $ka]] < 0} {
|
|
||||||
lset vdownptr($view) 0 $a
|
|
||||||
lappend vleftptr($view) $ka
|
|
||||||
} else {
|
|
||||||
while {[set b [lindex $vleftptr($view) $ka]] != 0 &&
|
|
||||||
[string compare $tok [lindex $varctok($view) $b]] >= 0} {
|
|
||||||
set ka $b
|
|
||||||
}
|
|
||||||
lset vleftptr($view) $ka $a
|
|
||||||
lappend vleftptr($view) $b
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
set tok {}
|
set tok {}
|
||||||
foreach k $children($vid) {
|
}
|
||||||
set ka $varcid($view,$k)
|
set ka 0
|
||||||
if {[string compare [lindex $varctok($view) $ka] $tok] > 0} {
|
if {[llength $children($vid)] > 0} {
|
||||||
set ki $k
|
set kid [lindex $children($vid) end]
|
||||||
set tok [lindex $varctok($view) $ka]
|
set k $varcid($view,$kid)
|
||||||
}
|
if {[string compare [lindex $varctok($view) $k] $tok] > 0} {
|
||||||
|
set ki $kid
|
||||||
|
set ka $k
|
||||||
|
set tok [lindex $varctok($view) $k]
|
||||||
}
|
}
|
||||||
set ka $varcid($view,$ki)
|
}
|
||||||
lappend vupptr($view) $ka
|
if {$ka != 0} {
|
||||||
set i [lsearch -exact $parents($view,$ki) $id]
|
set i [lsearch -exact $parents($view,$ki) $id]
|
||||||
set j [expr {[llength $parents($view,$ki)] - 1 - $i}]
|
set j [expr {[llength $parents($view,$ki)] - 1 - $i}]
|
||||||
set rsib 0
|
|
||||||
while {[incr i] < [llength $parents($view,$ki)]} {
|
|
||||||
set bi [lindex $parents($view,$ki) $i]
|
|
||||||
if {[info exists varcid($view,$bi)]} {
|
|
||||||
set b $varcid($view,$bi)
|
|
||||||
if {[lindex $vupptr($view) $b] == $ka} {
|
|
||||||
set rsib $b
|
|
||||||
lappend vleftptr($view) [lindex $vleftptr($view) $b]
|
|
||||||
lset vleftptr($view) $b $a
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if {$rsib == 0} {
|
|
||||||
lappend vleftptr($view) [lindex $vdownptr($view) $ka]
|
|
||||||
lset vdownptr($view) $ka $a
|
|
||||||
}
|
|
||||||
append tok [strrep $j]
|
append tok [strrep $j]
|
||||||
}
|
}
|
||||||
|
set c [lindex $vlastins($view) $ka]
|
||||||
|
if {$c == 0 || [string compare $tok [lindex $varctok($view) $c]] < 0} {
|
||||||
|
set c $ka
|
||||||
|
set b [lindex $vdownptr($view) $ka]
|
||||||
|
} else {
|
||||||
|
set b [lindex $vleftptr($view) $c]
|
||||||
|
}
|
||||||
|
while {$b != 0 && [string compare $tok [lindex $varctok($view) $b]] >= 0} {
|
||||||
|
set c $b
|
||||||
|
set b [lindex $vleftptr($view) $c]
|
||||||
|
}
|
||||||
|
if {$c == $ka} {
|
||||||
|
lset vdownptr($view) $ka $a
|
||||||
|
lappend vbackptr($view) 0
|
||||||
|
} else {
|
||||||
|
lset vleftptr($view) $c $a
|
||||||
|
lappend vbackptr($view) $c
|
||||||
|
}
|
||||||
|
lset vlastins($view) $ka $a
|
||||||
|
lappend vupptr($view) $ka
|
||||||
|
lappend vleftptr($view) $b
|
||||||
|
if {$b != 0} {
|
||||||
|
lset vbackptr($view) $b $a
|
||||||
|
}
|
||||||
lappend varctok($view) $tok
|
lappend varctok($view) $tok
|
||||||
lappend varcstart($view) $id
|
lappend varcstart($view) $id
|
||||||
lappend vdownptr($view) 0
|
lappend vdownptr($view) 0
|
||||||
lappend varcrow($view) {}
|
lappend varcrow($view) {}
|
||||||
lappend varcix($view) {}
|
lappend varcix($view) {}
|
||||||
set varccommits($view,$a) {}
|
set varccommits($view,$a) {}
|
||||||
|
lappend vlastins($view) 0
|
||||||
return $a
|
return $a
|
||||||
}
|
}
|
||||||
|
|
||||||
proc splitvarc {p v} {
|
proc splitvarc {p v} {
|
||||||
global varcid varcstart varccommits varctok
|
global varcid varcstart varccommits varctok
|
||||||
global vupptr vdownptr vleftptr varcix varcrow
|
global vupptr vdownptr vleftptr vbackptr varcix varcrow vlastins
|
||||||
|
|
||||||
set oa $varcid($v,$p)
|
set oa $varcid($v,$p)
|
||||||
set ac $varccommits($v,$oa)
|
set ac $varccommits($v,$oa)
|
||||||
@ -405,6 +404,8 @@ proc splitvarc {p v} {
|
|||||||
lset vdownptr($v) $oa $na
|
lset vdownptr($v) $oa $na
|
||||||
lappend vupptr($v) $oa
|
lappend vupptr($v) $oa
|
||||||
lappend vleftptr($v) 0
|
lappend vleftptr($v) 0
|
||||||
|
lappend vbackptr($v) 0
|
||||||
|
lappend vlastins($v) 0
|
||||||
for {set b [lindex $vdownptr($v) $na]} {$b != 0} {set b [lindex $vleftptr($v) $b]} {
|
for {set b [lindex $vdownptr($v) $na]} {$b != 0} {set b [lindex $vleftptr($v) $b]} {
|
||||||
lset vupptr($v) $b $na
|
lset vupptr($v) $b $na
|
||||||
}
|
}
|
||||||
@ -412,11 +413,12 @@ proc splitvarc {p v} {
|
|||||||
|
|
||||||
proc renumbervarc {a v} {
|
proc renumbervarc {a v} {
|
||||||
global parents children varctok varcstart varccommits
|
global parents children varctok varcstart varccommits
|
||||||
global vupptr vdownptr vleftptr varcid vtokmod
|
global vupptr vdownptr vleftptr vbackptr vlastins varcid vtokmod datemode
|
||||||
|
|
||||||
set t1 [clock clicks -milliseconds]
|
set t1 [clock clicks -milliseconds]
|
||||||
set todo {}
|
set todo {}
|
||||||
set isrelated($a) 1
|
set isrelated($a) 1
|
||||||
|
set kidchanged($a) 1
|
||||||
set ntot 0
|
set ntot 0
|
||||||
while {$a != 0} {
|
while {$a != 0} {
|
||||||
if {[info exists isrelated($a)]} {
|
if {[info exists isrelated($a)]} {
|
||||||
@ -440,26 +442,45 @@ proc renumbervarc {a v} {
|
|||||||
set a $b
|
set a $b
|
||||||
}
|
}
|
||||||
foreach a $todo {
|
foreach a $todo {
|
||||||
|
if {![info exists kidchanged($a)]} continue
|
||||||
set id [lindex $varcstart($v) $a]
|
set id [lindex $varcstart($v) $a]
|
||||||
set tok {}
|
if {[llength $children($v,$id)] > 1} {
|
||||||
foreach k $children($v,$id) {
|
set children($v,$id) [lsort -command [list vtokcmp $v] \
|
||||||
set ka $varcid($v,$k)
|
$children($v,$id)]
|
||||||
if {[string compare [lindex $varctok($v) $ka] $tok] > 0} {
|
}
|
||||||
set ki $k
|
set oldtok [lindex $varctok($v) $a]
|
||||||
set tok [lindex $varctok($v) $ka]
|
if {!$datemode} {
|
||||||
|
set tok {}
|
||||||
|
} else {
|
||||||
|
set tok $oldtok
|
||||||
|
}
|
||||||
|
set ka 0
|
||||||
|
if {[llength $children($v,$id)] > 0} {
|
||||||
|
set kid [lindex $children($v,$id) end]
|
||||||
|
set k $varcid($v,$kid)
|
||||||
|
if {[string compare [lindex $varctok($v) $k] $tok] > 0} {
|
||||||
|
set ki $kid
|
||||||
|
set ka $k
|
||||||
|
set tok [lindex $varctok($v) $k]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if {$tok ne {}} {
|
if {$ka != 0} {
|
||||||
set ka $varcid($v,$ki)
|
|
||||||
set i [lsearch -exact $parents($v,$ki) $id]
|
set i [lsearch -exact $parents($v,$ki) $id]
|
||||||
set j [expr {[llength $parents($v,$ki)] - 1 - $i}]
|
set j [expr {[llength $parents($v,$ki)] - 1 - $i}]
|
||||||
append tok [strrep $j]
|
append tok [strrep $j]
|
||||||
set oldtok [lindex $varctok($v) $a]
|
|
||||||
if {$tok eq $oldtok} continue
|
|
||||||
lset varctok($v) $a $tok
|
|
||||||
} else {
|
|
||||||
set ka 0
|
|
||||||
}
|
}
|
||||||
|
if {$tok eq $oldtok} {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
set id [lindex $varccommits($v,$a) end]
|
||||||
|
foreach p $parents($v,$id) {
|
||||||
|
if {[info exists varcid($v,$p)]} {
|
||||||
|
set kidchanged($varcid($v,$p)) 1
|
||||||
|
} else {
|
||||||
|
set sortkids($p) 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lset varctok($v) $a $tok
|
||||||
set b [lindex $vupptr($v) $a]
|
set b [lindex $vupptr($v) $a]
|
||||||
if {$b != $ka} {
|
if {$b != $ka} {
|
||||||
if {[string compare [lindex $varctok($v) $ka] $vtokmod($v)] < 0} {
|
if {[string compare [lindex $varctok($v) $ka] $vtokmod($v)] < 0} {
|
||||||
@ -468,38 +489,48 @@ proc renumbervarc {a v} {
|
|||||||
if {[string compare [lindex $varctok($v) $b] $vtokmod($v)] < 0} {
|
if {[string compare [lindex $varctok($v) $b] $vtokmod($v)] < 0} {
|
||||||
modify_arc $v $b
|
modify_arc $v $b
|
||||||
}
|
}
|
||||||
set c [lindex $vdownptr($v) $b]
|
set c [lindex $vbackptr($v) $a]
|
||||||
if {$c == $a} {
|
set d [lindex $vleftptr($v) $a]
|
||||||
lset vdownptr($v) $b [lindex $vleftptr($v) $a]
|
if {$c == 0} {
|
||||||
|
lset vdownptr($v) $b $d
|
||||||
} else {
|
} else {
|
||||||
set b $c
|
lset vleftptr($v) $c $d
|
||||||
while {$b != 0 && [lindex $vleftptr($v) $b] != $a} {
|
}
|
||||||
set b [lindex $vleftptr($v) $b]
|
if {$d != 0} {
|
||||||
}
|
lset vbackptr($v) $d $c
|
||||||
if {$b != 0} {
|
|
||||||
lset vleftptr($v) $b [lindex $vleftptr($v) $a]
|
|
||||||
} else {
|
|
||||||
puts "oops couldn't find $a in chain for [lindex $vupptr($v) $a]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
lset vupptr($v) $a $ka
|
lset vupptr($v) $a $ka
|
||||||
set rsib 0
|
set c [lindex $vlastins($v) $ka]
|
||||||
while {[incr i] < [llength $parents($v,$ki)]} {
|
if {$c == 0 || \
|
||||||
set bi [lindex $parents($v,$ki) $i]
|
[string compare $tok [lindex $varctok($v) $c]] < 0} {
|
||||||
if {[info exists varcid($v,$bi)]} {
|
set c $ka
|
||||||
set b $varcid($v,$bi)
|
set b [lindex $vdownptr($v) $ka]
|
||||||
if {[lindex $vupptr($v) $b] == $ka} {
|
} else {
|
||||||
set rsib $b
|
set b [lindex $vleftptr($v) $c]
|
||||||
lset vleftptr($v) $a [lindex $vleftptr($v) $b]
|
|
||||||
lset vleftptr($v) $b $a
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if {$rsib == 0} {
|
while {$b != 0 && \
|
||||||
lset vleftptr($v) $a [lindex $vdownptr($v) $ka]
|
[string compare $tok [lindex $varctok($v) $b]] >= 0} {
|
||||||
lset vdownptr($v) $ka $a
|
set c $b
|
||||||
|
set b [lindex $vleftptr($v) $c]
|
||||||
}
|
}
|
||||||
|
if {$c == $ka} {
|
||||||
|
lset vdownptr($v) $ka $a
|
||||||
|
lset vbackptr($v) $a 0
|
||||||
|
} else {
|
||||||
|
lset vleftptr($v) $c $a
|
||||||
|
lset vbackptr($v) $a $c
|
||||||
|
}
|
||||||
|
lset vleftptr($v) $a $b
|
||||||
|
if {$b != 0} {
|
||||||
|
lset vbackptr($v) $b $a
|
||||||
|
}
|
||||||
|
lset vlastins($v) $ka $a
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach id [array names sortkids] {
|
||||||
|
if {[llength $children($v,$id)] > 1} {
|
||||||
|
set children($v,$id) [lsort -command [list vtokcmp $v] \
|
||||||
|
$children($v,$id)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set t2 [clock clicks -milliseconds]
|
set t2 [clock clicks -milliseconds]
|
||||||
@ -831,7 +862,7 @@ proc closevarcs {v} {
|
|||||||
|
|
||||||
proc getcommitlines {fd inst view} {
|
proc getcommitlines {fd inst view} {
|
||||||
global cmitlisted commitinterest leftover
|
global cmitlisted commitinterest leftover
|
||||||
global commitidx commitdata
|
global commitidx commitdata datemode
|
||||||
global parents children curview hlview
|
global parents children curview hlview
|
||||||
global vnextroot idpending ordertok
|
global vnextroot idpending ordertok
|
||||||
global varccommits varcid varctok vtokmod
|
global varccommits varcid varctok vtokmod
|
||||||
@ -946,12 +977,12 @@ proc getcommitlines {fd inst view} {
|
|||||||
set a 0
|
set a 0
|
||||||
if {![info exists children($vid)]} {
|
if {![info exists children($vid)]} {
|
||||||
set children($vid) {}
|
set children($vid) {}
|
||||||
} else {
|
} elseif {[llength $children($vid)] == 1} {
|
||||||
if {[llength $children($vid)] == 1} {
|
set k [lindex $children($vid) 0]
|
||||||
set k [lindex $children($vid) 0]
|
if {[llength $parents($view,$k)] == 1 &&
|
||||||
if {[llength $parents($view,$k)] == 1} {
|
(!$datemode ||
|
||||||
set a $varcid($view,$k)
|
$varcid($view,$k) == [llength $varctok($view)] - 1)} {
|
||||||
}
|
set a $varcid($view,$k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if {$a == 0} {
|
if {$a == 0} {
|
||||||
@ -974,9 +1005,9 @@ proc getcommitlines {fd inst view} {
|
|||||||
$children($vp)]
|
$children($vp)]
|
||||||
catch {unset ordertok}
|
catch {unset ordertok}
|
||||||
}
|
}
|
||||||
}
|
if {[info exists varcid($view,$p)]} {
|
||||||
if {[info exists varcid($view,$p)]} {
|
fix_reversal $p $a $view
|
||||||
fix_reversal $p $a $view
|
}
|
||||||
}
|
}
|
||||||
incr i
|
incr i
|
||||||
}
|
}
|
||||||
@ -1033,7 +1064,7 @@ proc chewcommits {view} {
|
|||||||
if {$view == $curview} {
|
if {$view == $curview} {
|
||||||
layoutmore
|
layoutmore
|
||||||
if {$viewcomplete($view)} {
|
if {$viewcomplete($view)} {
|
||||||
global commitidx
|
global commitidx varctok
|
||||||
global numcommits startmsecs
|
global numcommits startmsecs
|
||||||
global mainheadid commitinfo nullid
|
global mainheadid commitinfo nullid
|
||||||
|
|
||||||
@ -1044,6 +1075,7 @@ proc chewcommits {view} {
|
|||||||
if {$commitidx($curview) > 0} {
|
if {$commitidx($curview) > 0} {
|
||||||
#set ms [expr {[clock clicks -milliseconds] - $startmsecs}]
|
#set ms [expr {[clock clicks -milliseconds] - $startmsecs}]
|
||||||
#puts "overall $ms ms for $numcommits commits"
|
#puts "overall $ms ms for $numcommits commits"
|
||||||
|
#puts "[llength $varctok($view)] arcs, $commitidx($view) commits"
|
||||||
} else {
|
} else {
|
||||||
show_status "No commits selected"
|
show_status "No commits selected"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user