80
settextcursor watch
81
}
82
83
+proc stop_rev_list {} {
84
+ global commfd
85
+
86
+ if {![info exists commfd]} return
87
+ catch {
88
+ set pid [pid $commfd]
89
+ exec kill $pid
90
+ }
91
+ catch {close $commfd}
92
+ unset commfd
93
+}
94
+
95
proc getcommits {rargs} {
96
global phase canv mainfont
97
185
lappend parentlist $olds
186
if {[info exists children($id)]} {
187
lappend childlist $children($id)
188
+ unset children($id)
189
} else {
190
lappend childlist {}
191
}
230
}
231
232
proc updatecommits {} {
220
- global viewdata curview revtreeargs
233
+ global viewdata curview revtreeargs phase
234
235
+ if {$phase ne {}} {
236
+ stop_rev_list
237
+ set phase {}
238
+ }
239
set n $curview
240
set curview -1
241
catch {unset viewdata($n)}
900
showview 0
901
}
902
903
+proc flatten {var} {
904
+ global $var
905
+
906
+ set ret {}
907
+ foreach i [array names $var] {
908
+ lappend ret $i [set $var\($i\)]
909
+ }
910
+ return $ret
911
+}
912
+
913
+proc unflatten {var l} {
914
+ global $var
915
+
916
+ catch {unset $var}
917
+ foreach {i v} $l {
918
+ set $var\($i\) $v
919
+ }
920
+}
921
+
922
proc showview {n} {
923
global curview viewdata viewfiles
924
global displayorder parentlist childlist rowidlist rowoffsets
928
global matchinglines treediffs
929
global parsed_args
930
global pending_select phase
931
+ global commitidx rowlaidout rowoptim linesegends leftover
932
+ global commfd nextupdate
933
934
if {$n == $curview} return
935
set selid {}
949
unselectline
950
normalline
951
stopfindproc
914
- if {$curview >= 0 && $phase eq {} && ![info exists viewdata($curview)]} {
915
- set viewdata($curview) \
916
- [list $displayorder $parentlist $childlist $rowidlist \
917
- $rowoffsets $rowrangelist $commitlisted]
952
+ if {$curview >= 0} {
953
+ if {$phase ne {}} {
954
+ set viewdata($curview) \
955
+ [list $phase $displayorder $parentlist $childlist $rowidlist \
956
+ $rowoffsets $rowrangelist $commitlisted \
957
+ [flatten children] [flatten idrowranges] \
958
+ [flatten idinlist] \
959
+ $commitidx $rowlaidout $rowoptim $numcommits \
960
+ $linesegends $leftover $commfd]
961
+ fileevent $commfd readable {}
962
+ } elseif {![info exists viewdata($curview)]} {
963
+ set viewdata($curview) \
964
+ [list {} $displayorder $parentlist $childlist $rowidlist \
965
+ $rowoffsets $rowrangelist $commitlisted]
966
+ }
967
}
968
catch {unset matchinglines}
969
catch {unset treediffs}
982
return
983
}
984
936
- set displayorder [lindex $viewdata($n) 0]
937
- set parentlist [lindex $viewdata($n) 1]
938
- set childlist [lindex $viewdata($n) 2]
939
- set rowidlist [lindex $viewdata($n) 3]
940
- set rowoffsets [lindex $viewdata($n) 4]
941
- set rowrangelist [lindex $viewdata($n) 5]
942
- set commitlisted [lindex $viewdata($n) 6]
943
- set numcommits [llength $displayorder]
985
+ set v $viewdata($n)
986
+ set phase [lindex $v 0]
987
+ set displayorder [lindex $v 1]
988
+ set parentlist [lindex $v 2]
989
+ set childlist [lindex $v 3]
990
+ set rowidlist [lindex $v 4]
991
+ set rowoffsets [lindex $v 5]
992
+ set rowrangelist [lindex $v 6]
993
+ set commitlisted [lindex $v 7]
994
+ if {$phase eq {}} {
995
+ set numcommits [llength $displayorder]
996
+ catch {unset idrowranges}
997
+ catch {unset children}
998
+ } else {
999
+ unflatten children [lindex $v 8]
1000
+ unflatten idrowranges [lindex $v 9]
1001
+ unflatten idinlist [lindex $v 10]
1002
+ set commitidx [lindex $v 11]
1003
+ set rowlaidout [lindex $v 12]
1004
+ set rowoptim [lindex $v 13]
1005
+ set numcommits [lindex $v 14]
1006
+ set linesegends [lindex $v 15]
1007
+ set leftover [lindex $v 16]
1008
+ set commfd [lindex $v 17]
1009
+ fileevent $commfd readable [list getcommitlines $commfd]
1010
+ set nextupdate [expr {[clock clicks -milliseconds] + 100}]
1011
+ }
1012
+
1013
catch {unset colormap}
1014
catch {unset rowtextx}
1015
catch {unset commitrow}
947
- catch {unset idrowranges}
1016
set curview $n
1017
set row 0
1018
foreach id $displayorder {
1072
}
1073
1074
proc usedinrange {id l1 l2} {
1007
- global children commitrow
1075
+ global children commitrow childlist
1076
1077
if {[info exists commitrow($id)]} {
1078
set r $commitrow($id)
1079
if {$l1 <= $r && $r <= $l2} {
1080
return [expr {$r - $l1 + 1}]
1081
}
1082
+ set kids [lindex $childlist $r]
1083
+ } else {
1084
+ set kids $children($id)
1085
}
1015
- foreach c $children($id) {
1016
- if {[info exists commitrow($c)]} {
1017
- set r $commitrow($c)
1018
- if {$l1 <= $r && $r <= $l2} {
1019
- return [expr {$r - $l1 + 1}]
1020
- }
1086
+ foreach c $kids {
1087
+ set r $commitrow($c)
1088
+ if {$l1 <= $r && $r <= $l2} {
1089
+ return [expr {$r - $l1 + 1}]
1090
}
1091
}
1092
return 0
1181
catch {unset rowtextx}
1182
catch {unset commitrow}
1183
catch {unset idrowranges}
1115
- catch {unset linesegends}
1184
+ set linesegends {}
1185
}
1186
1187
proc setcanvscroll {} {
1246
set r1 [lindex $rows 1]
1247
set selrow -1
1248
for {set r $row} {$r < $canshow} {incr r} {
1180
- if {[info exists linesegends($r)]} {
1181
- foreach id $linesegends($r) {
1182
- set i -1
1183
- foreach {s e} $idrowranges($id) {
1184
- incr i
1185
- if {$e ne {} && $e < $numcommits && $s <= $r1 && $e >= $r0
1186
- && ![info exists idrangedrawn($id,$i)]} {
1187
- drawlineseg $id $i
1188
- set idrangedrawn($id,$i) 1
1189
- }
1249
+ foreach id [lindex $linesegends [expr {$r+1}]] {
1250
+ set i -1
1251
+ foreach {s e} [rowranges $id] {
1252
+ incr i
1253
+ if {$e ne {} && $e < $numcommits && $s <= $r1 && $e >= $r0
1254
+ && ![info exists idrangedrawn($id,$i)]} {
1255
+ drawlineseg $id $i
1256
+ set idrangedrawn($id,$i) 1
1257
}
1258
}
1259
}
1296
lappend oldolds $p
1297
}
1298
}
1299
+ set lse {}
1300
set nev [expr {[llength $idlist] + [llength $newolds]
1301
+ [llength $oldolds] - $maxwidth + 1}]
1302
if {$nev > 0} {
1312
set offs [incrange $offs $x 1]
1313
set idinlist($i) 0
1314
set rm1 [expr {$row - 1}]
1247
- lappend linesegends($rm1) $i
1315
+ lappend lse $i
1316
lappend idrowranges($i) $rm1
1317
if {[incr nev -1] <= 0} break
1318
continue
1323
lset rowidlist $row $idlist
1324
lset rowoffsets $row $offs
1325
}
1326
+ lappend linesegends $lse
1327
set col [lsearch -exact $idlist $id]
1328
if {$col < 0} {
1329
set col [llength $idlist]
1344
}
1345
set ranges {}
1346
if {[info exists idrowranges($id)]} {
1278
- lappend idrowranges($id) $row
1347
set ranges $idrowranges($id)
1348
+ lappend ranges $row
1349
+ unset idrowranges($id)
1350
}
1351
lappend rowrangelist $ranges
1352
incr row
1401
}
1402
if {[info exists children($id)]} {
1403
lappend childlist $children($id)
1404
+ unset children($id)
1405
} else {
1406
lappend childlist {}
1407
}
1420
unset idinlist($id)
1421
lappend idrowranges($id) $row
1422
lappend rowrangelist $idrowranges($id)
1423
+ unset idrowranges($id)
1424
incr row
1425
set offs [ntimes $col 0]
1426
set idlist [lreplace $idlist $col $col]
1435
makeuparrow $id 0 $row 0
1436
lappend idrowranges($id) $row
1437
lappend rowrangelist $idrowranges($id)
1438
+ unset idrowranges($id)
1439
incr row
1440
lappend rowidlist {}
1441
lappend rowoffsets {}
1471
set z0 [lindex $rowoffsets $y0 $x0]
1472
if {$z0 eq {}} {
1473
set id [lindex $idlist $col]
1401
- if {[info exists idrowranges($id)] &&
1402
- $y0 > [lindex $idrowranges($id) 0]} {
1474
+ set ranges [rowranges $id]
1475
+ if {$ranges ne {} && $y0 > [lindex $ranges 0]} {
1476
set isarrow 1
1477
}
1478
}
1530
if {$o eq {}} {
1531
# check if this is the link to the first child
1532
set id [lindex $idlist $col]
1460
- if {[info exists idrowranges($id)] &&
1461
- $row == [lindex $idrowranges($id) 0]} {
1533
+ set ranges [rowranges $id]
1534
+ if {$ranges ne {} && $row == [lindex $ranges 0]} {
1535
# it is, work out offset to child
1536
set y0 [expr {$row - 1}]
1537
set id [lindex $displayorder $y0]
1586
}
1587
1588
proc rowranges {id} {
1516
- global idrowranges commitrow numcommits rowrangelist
1589
+ global phase idrowranges commitrow rowlaidout rowrangelist
1590
1591
set ranges {}
1519
- if {[info exists commitrow($id)] && $commitrow($id) < $numcommits} {
1592
+ if {$phase eq {} ||
1593
+ ([info exists commitrow($id)] && $commitrow($id) < $rowlaidout)} {
1594
set ranges [lindex $rowrangelist $commitrow($id)]
1595
} elseif {[info exists idrowranges($id)]} {
1596
set ranges $idrowranges($id)
1801
1802
if {$row >= $numcommits} return
1803
foreach id [lindex $rowidlist $row] {
1804
+ if {$id eq {}} continue
1805
set i -1
1806
foreach {s e} [rowranges $id] {
1807
incr i
3217
foreach e $entries {
3218
$e conf -font $mainfont
3219
}
3145
- if {$phase == "getcommits"} {
3220
+ if {$phase eq "getcommits"} {
3221
$canv itemconf textitems -font $mainfont
3222
}
3223
redisplay