307
global startmsecs commitidx viewcomplete curview
308
global tclencoding
309
global viewargs viewargscmd viewfiles vfilelimit
310
- global showlocalchanges commitinterest
310
+ global showlocalchanges
311
global viewactive viewinstances vmergeonly
312
global mainheadid
313
global vcanopt vflags vrevs vorigargs
368
set i [reg_instance $fd]
369
set viewinstances($view) [list $i]
370
if {$showlocalchanges && $mainheadid ne {}} {
371
- lappend commitinterest($mainheadid) {dodiffindex}
371
+ interestedin $mainheadid dodiffindex
372
}
373
fconfigure $fd -blocking 0 -translation lf -eofchar {}
374
if {$tclencoding != {}} {
1231
1232
proc closevarcs {v} {
1233
global varctok varccommits varcid parents children
1234
- global cmitlisted commitidx commitinterest vtokmod
1234
+ global cmitlisted commitidx vtokmod
1235
1236
set missing_parents 0
1237
set scripts {}
1256
}
1257
lappend varccommits($v,$b) $p
1258
incr commitidx($v)
1259
- if {[info exists commitinterest($p)]} {
1260
- foreach script $commitinterest($p) {
1261
- lappend scripts [string map [list "%I" $p] $script]
1262
- }
1263
- unset commitinterest($id)
1264
- }
1259
+ set scripts [check_interest $p $scripts]
1260
}
1261
}
1262
if {$missing_parents > 0} {
1292
}
1293
}
1294
1295
+# Mechanism for registering a command to be executed when we come
1296
+# across a particular commit. To handle the case when only the
1297
+# prefix of the commit is known, the commitinterest array is now
1298
+# indexed by the first 4 characters of the ID. Each element is a
1299
+# list of id, cmd pairs.
1300
+proc interestedin {id cmd} {
1301
+ global commitinterest
1302
+
1303
+ lappend commitinterest([string range $id 0 3]) $id $cmd
1304
+}
1305
+
1306
+proc check_interest {id scripts} {
1307
+ global commitinterest
1308
+
1309
+ set prefix [string range $id 0 3]
1310
+ if {[info exists commitinterest($prefix)]} {
1311
+ set newlist {}
1312
+ foreach {i script} $commitinterest($prefix) {
1313
+ if {[string match "$i*" $id]} {
1314
+ lappend scripts [string map [list "%I" $id "%P" $i] $script]
1315
+ } else {
1316
+ lappend newlist $i $script
1317
+ }
1318
+ }
1319
+ if {$newlist ne {}} {
1320
+ set commitinterest($prefix) $newlist
1321
+ } else {
1322
+ unset commitinterest($prefix)
1323
+ }
1324
+ }
1325
+ return $scripts
1326
+}
1327
+
1328
proc getcommitlines {fd inst view updating} {
1301
- global cmitlisted commitinterest leftover
1329
+ global cmitlisted leftover
1330
global commitidx commitdata vdatemode
1331
global parents children curview hlview
1332
global idpending ordertok
1502
incr i
1503
}
1504
1477
- if {[info exists commitinterest($id)]} {
1478
- foreach script $commitinterest($id) {
1479
- lappend scripts [string map [list "%I" $id] $script]
1480
- }
1481
- unset commitinterest($id)
1482
- }
1505
+ set scripts [check_interest $id $scripts]
1506
set gotsome 1
1507
}
1508
if {$gotsome} {
1631
return 1
1632
}
1633
1634
+# Expand an abbreviated commit ID to a list of full 40-char IDs that match
1635
+# and are present in the current view.
1636
+# This is fairly slow...
1637
+proc longid {prefix} {
1638
+ global varcid curview
1639
+
1640
+ set ids {}
1641
+ foreach match [array names varcid "$curview,$prefix*"] {
1642
+ lappend ids [lindex [split $match ","] 1]
1643
+ }
1644
+ return $ids
1645
+}
1646
+
1647
proc readrefs {} {
1648
global tagids idtags headids idheads tagobjid
1649
global otherrefids idotherrefs mainhead mainheadid
4155
proc layoutmore {} {
4156
global commitidx viewcomplete curview
4157
global numcommits pending_select curview
4122
- global lastscrollset lastscrollrows commitinterest
4158
+ global lastscrollset lastscrollrows
4159
4160
if {$lastscrollrows < 100 || $viewcomplete($curview) ||
4161
[clock clicks -milliseconds] - $lastscrollset > 500} {
4176
if {[commitinview $mainheadid $curview]} {
4177
dodiffindex
4178
} else {
4143
- lappend commitinterest($mainheadid) {dodiffindex}
4179
+ interestedin $mainheadid dodiffindex
4180
}
4181
}
4182
5831
# append some text to the ctext widget, and make any SHA1 ID
5832
# that we know about be a clickable link.
5833
proc appendwithlinks {text tags} {
5798
- global ctext linknum curview pendinglinks
5834
+ global ctext linknum curview
5835
5836
set start [$ctext index "end - 1c"]
5837
$ctext insert end $text $tags
5802
- set links [regexp -indices -all -inline {[0-9a-f]{40}} $text]
5838
+ set links [regexp -indices -all -inline {\m[0-9a-f]{6,40}\M} $text]
5839
foreach l $links {
5840
set s [lindex $l 0]
5841
set e [lindex $l 1]
5849
}
5850
5851
proc setlink {id lk} {
5816
- global curview ctext pendinglinks commitinterest
5852
+ global curview ctext pendinglinks
5853
5818
- if {[commitinview $id $curview]} {
5854
+ set known 0
5855
+ if {[string length $id] < 40} {
5856
+ set matches [longid $id]
5857
+ if {[llength $matches] > 0} {
5858
+ if {[llength $matches] > 1} return
5859
+ set known 1
5860
+ set id [lindex $matches 0]
5861
+ }
5862
+ } else {
5863
+ set known [commitinview $id $curview]
5864
+ }
5865
+ if {$known} {
5866
$ctext tag conf $lk -foreground blue -underline 1
5820
- $ctext tag bind $lk <1> [list selectline [rowofcommit $id] 1]
5867
+ $ctext tag bind $lk <1> [list selbyid $id]
5868
$ctext tag bind $lk <Enter> {linkcursor %W 1}
5869
$ctext tag bind $lk <Leave> {linkcursor %W -1}
5870
} else {
5871
lappend pendinglinks($id) $lk
5825
- lappend commitinterest($id) {makelink %I}
5872
+ interestedin $id {makelink %P}
5873
}
5874
}
5875
7185
} else {
7186
set id [string tolower $sha1string]
7187
if {[regexp {^[0-9a-f]{4,39}$} $id]} {
7141
- set matches [array names varcid "$curview,$id*"]
7188
+ set matches [longid $id]
7189
if {$matches ne {}} {
7190
if {[llength $matches] > 1} {
7191
error_popup [mc "Short SHA1 id %s is ambiguous" $id]
7192
return
7193
}
7147
- set id [lindex [split [lindex $matches 0] ","] 1]
7194
+ set id [lindex $matches 0]
7195
}
7196
}
7197
}
8039
8040
proc refill_reflist {} {
8041
global reflist reflistfilter showrefstop headids tagids otherrefids
7995
- global curview commitinterest
8042
+ global curview
8043
8044
if {![info exists showrefstop] || ![winfo exists $showrefstop]} return
8045
set refs {}
8048
if {[commitinview $headids($n) $curview]} {
8049
lappend refs [list $n H]
8050
} else {
8004
- set commitinterest($headids($n)) {run refill_reflist}
8051
+ interestedin $headids($n) {run refill_reflist}
8052
}
8053
}
8054
}
8057
if {[commitinview $tagids($n) $curview]} {
8058
lappend refs [list $n T]
8059
} else {
8013
- set commitinterest($tagids($n)) {run refill_reflist}
8060
+ interestedin $tagids($n) {run refill_reflist}
8061
}
8062
}
8063
}
8066
if {[commitinview $otherrefids($n) $curview]} {
8067
lappend refs [list $n o]
8068
} else {
8022
- set commitinterest($otherrefids($n)) {run refill_reflist}
8069
+ interestedin $otherrefids($n) {run refill_reflist}
8070
}
8071
}
8072
}