47
lappend runq [list $fd $script]
48
}
49
50
+proc nukefile {fd} {
51
+ global runq
52
+
53
+ for {set i 0} {$i < [llength $runq]} {} {
54
+ if {[lindex $runq $i 0] eq $fd} {
55
+ set runq [lreplace $runq $i $i]
56
+ } else {
57
+ incr i
58
+ }
59
+ }
60
+}
61
+
62
proc dorunq {} {
63
global isonrunq runq
64
65
set tstart [clock clicks -milliseconds]
66
set t0 $tstart
55
- while {$runq ne {}} {
67
+ while {[llength $runq] > 0} {
68
set fd [lindex $runq 0 0]
69
set script [lindex $runq 0 1]
70
set repeat [eval $script]
97
global viewargs viewfiles commitidx viewcomplete vnextroot
98
global showlocalchanges commitinterest mainheadid
99
global progressdirn progresscoords proglastnc curview
100
+ global viewincl viewactive loginstance viewinstances
101
102
set startmsecs [clock clicks -milliseconds]
103
set commitidx($view) 0
104
set viewcomplete($view) 0
105
+ set viewactive($view) 1
106
set vnextroot($view) 0
93
- set order "--topo-order"
94
- if {$datemode} {
95
- set order "--date-order"
107
+ varcinit $view
108
+
109
+ set commits [exec git rev-parse --default HEAD --revs-only \
110
+ $viewargs($view)]
111
+ set viewincl($view) {}
112
+ foreach c $commits {
113
+ if {![string match "^*" $c]} {
114
+ lappend viewincl($view) $c
115
+ }
116
}
117
if {[catch {
98
- set fd [open [concat | git log --no-color -z --pretty=raw $order --parents \
99
- --boundary $viewargs($view) "--" $viewfiles($view)] r]
118
+ set fd [open [concat | git log --no-color -z --pretty=raw --parents \
119
+ --boundary $commits "--" $viewfiles($view)] r]
120
} err]} {
101
- error_popup "Error executing git rev-list: $err"
121
+ error_popup "Error executing git log: $err"
122
exit 1
123
}
104
- set commfd($view) $fd
105
- set leftover($view) {}
124
+ set i [incr loginstance]
125
+ set viewinstances($view) [list $i]
126
+ set commfd($i) $fd
127
+ set leftover($i) {}
128
if {$showlocalchanges} {
129
lappend commitinterest($mainheadid) {dodiffindex}
130
}
132
if {$tclencoding != {}} {
133
fconfigure $fd -encoding $tclencoding
134
}
113
- filerun $fd [list getcommitlines $fd $view]
135
+ filerun $fd [list getcommitlines $fd $i $view]
136
nowbusy $view "Reading"
137
if {$view == $curview} {
138
set progressdirn 1
141
}
142
}
143
122
-proc stop_rev_list {} {
123
- global commfd curview
144
+proc stop_rev_list {view} {
145
+ global commfd viewinstances leftover
146
125
- if {![info exists commfd($curview)]} return
126
- set fd $commfd($curview)
127
- catch {
128
- set pid [pid $fd]
129
- exec kill $pid
147
+ foreach inst $viewinstances($view) {
148
+ set fd $commfd($inst)
149
+ catch {
150
+ set pid [pid $fd]
151
+ exec kill $pid
152
+ }
153
+ catch {close $fd}
154
+ nukefile $fd
155
+ unset commfd($inst)
156
+ unset leftover($inst)
157
}
131
- catch {close $fd}
132
- unset commfd($curview)
158
+ set viewinstances($view) {}
159
}
160
161
proc getcommits {} {
136
- global phase canv curview
162
+ global canv curview
163
138
- set phase getcommits
164
initlayout
165
start_rev_list $curview
166
show_status "Reading commits..."
167
}
168
169
+proc updatecommits {} {
170
+ global curview viewargs viewfiles viewincl viewinstances
171
+ global viewactive viewcomplete loginstance tclencoding
172
+ global varcid startmsecs commfd getdbg showneartags leftover
173
+
174
+ set getdbg 1
175
+ set view $curview
176
+ set commits [exec git rev-parse --default HEAD --revs-only \
177
+ $viewargs($view)]
178
+ set pos {}
179
+ set neg {}
180
+ foreach c $commits {
181
+ if {[string match "^*" $c]} {
182
+ lappend neg $c
183
+ } else {
184
+ if {!([info exists varcid($view,$c)] ||
185
+ [lsearch -exact $viewincl($view) $c] >= 0)} {
186
+ lappend pos $c
187
+ }
188
+ }
189
+ }
190
+ if {$pos eq {}} {
191
+ return
192
+ }
193
+ foreach id $viewincl($view) {
194
+ lappend neg "^$id"
195
+ }
196
+ set viewincl($view) [concat $viewincl($view) $pos]
197
+ if {[catch {
198
+ set fd [open [concat | git log --no-color -z --pretty=raw --parents \
199
+ --boundary $pos $neg "--" $viewfiles($view)] r]
200
+ } err]} {
201
+ error_popup "Error executing git log: $err"
202
+ exit 1
203
+ }
204
+ if {$viewactive($view) == 0} {
205
+ set startmsecs [clock clicks -milliseconds]
206
+ }
207
+ set i [incr loginstance]
208
+ lappend viewinstances($view) $i
209
+ set commfd($i) $fd
210
+ set leftover($i) {}
211
+ fconfigure $fd -blocking 0 -translation lf -eofchar {}
212
+ if {$tclencoding != {}} {
213
+ fconfigure $fd -encoding $tclencoding
214
+ }
215
+ filerun $fd [list getcommitlines $fd $i $view]
216
+ incr viewactive($view)
217
+ set viewcomplete($view) 0
218
+ nowbusy $view "Reading"
219
+ readrefs
220
+ changedrefs
221
+ if {$showneartags} {
222
+ getallcommits
223
+ }
224
+}
225
+
226
+proc reloadcommits {} {
227
+ global curview viewcomplete selectedline currentid thickerline
228
+ global showneartags treediffs commitinterest cached_commitrow
229
+ global progresscoords
230
+
231
+ if {!$viewcomplete($curview)} {
232
+ stop_rev_list $curview
233
+ set progresscoords {0 0}
234
+ adjustprogress
235
+ }
236
+ resetvarcs $curview
237
+ catch {unset selectedline}
238
+ catch {unset currentid}
239
+ catch {unset thickerline}
240
+ catch {unset treediffs}
241
+ readrefs
242
+ changedrefs
243
+ if {$showneartags} {
244
+ getallcommits
245
+ }
246
+ clear_display
247
+ catch {unset commitinterest}
248
+ catch {unset cached_commitrow}
249
+ setcanvscroll
250
+ getcommits
251
+}
252
+
253
# This makes a string representation of a positive integer which
254
# sorts as a string in numerical order
255
proc strrep {n} {
263
return [format "z%.8x" $n]
264
}
265
157
-proc getcommitlines {fd view} {
158
- global commitlisted commitinterest
159
- global leftover commfd
160
- global displayorder commitidx viewcomplete commitrow commitdata
161
- global parentlist children curview hlview
162
- global vparentlist vdisporder vcmitlisted
266
+# Procedures used in reordering commits from git log (without
267
+# --topo-order) into the order for display.
268
+
269
+proc varcinit {view} {
270
+ global vseeds varcstart vupptr vdownptr vleftptr varctok varcrow
271
+ global vtokmod varcmod varcix uat
272
+
273
+ set vseeds($view) {}
274
+ set varcstart($view) {{}}
275
+ set vupptr($view) {0}
276
+ set vdownptr($view) {0}
277
+ set vleftptr($view) {0}
278
+ set varctok($view) {{}}
279
+ set varcrow($view) {{}}
280
+ set vtokmod($view) {}
281
+ set varcmod($view) 0
282
+ set varcix($view) {{}}
283
+ set uat 0
284
+}
285
+
286
+proc resetvarcs {view} {
287
+ global varcid varccommits parents children vseedcount ordertok
288
+
289
+ foreach vid [array names varcid $view,*] {
290
+ unset varcid($vid)
291
+ unset children($vid)
292
+ unset parents($vid)
293
+ }
294
+ # some commits might have children but haven't been seen yet
295
+ foreach vid [array names children $view,*] {
296
+ unset children($vid)
297
+ }
298
+ foreach va [array names varccommits $view,*] {
299
+ unset varccommits($va)
300
+ }
301
+ foreach vd [array names vseedcount $view,*] {
302
+ unset vseedcount($vd)
303
+ }
304
+ foreach vid [array names ordertok $view,*] {
305
+ unset ordertok($vid)
306
+ }
307
+}
308
+
309
+proc newvarc {view id} {
310
+ global varcid varctok parents children vseeds
311
+ global vupptr vdownptr vleftptr varcrow varcix varcstart
312
+ global commitdata commitinfo vseedcount
313
+
314
+ set a [llength $varctok($view)]
315
+ set vid $view,$id
316
+ if {[llength $children($vid)] == 0} {
317
+ if {![info exists commitinfo($id)]} {
318
+ parsecommit $id $commitdata($id) 1
319
+ }
320
+ set cdate [lindex $commitinfo($id) 4]
321
+ if {![string is integer -strict $cdate]} {
322
+ set cdate 0
323
+ }
324
+ if {![info exists vseedcount($view,$cdate)]} {
325
+ set vseedcount($view,$cdate) -1
326
+ }
327
+ set c [incr vseedcount($view,$cdate)]
328
+ set cdate [expr {$cdate ^ 0xffffffff}]
329
+ set tok "s[strrep $cdate][strrep $c]"
330
+ lappend vseeds($view) $id
331
+ lappend vupptr($view) 0
332
+ set ka [lindex $vdownptr($view) 0]
333
+ if {$ka == 0 ||
334
+ [string compare $tok [lindex $varctok($view) $ka]] < 0} {
335
+ lset vdownptr($view) 0 $a
336
+ lappend vleftptr($view) $ka
337
+ } else {
338
+ while {[set b [lindex $vleftptr($view) $ka]] != 0 &&
339
+ [string compare $tok [lindex $varctok($view) $b]] >= 0} {
340
+ set ka $b
341
+ }
342
+ lset vleftptr($view) $ka $a
343
+ lappend vleftptr($view) $b
344
+ }
345
+ } else {
346
+ set tok {}
347
+ foreach k $children($vid) {
348
+ set ka $varcid($view,$k)
349
+ if {[string compare [lindex $varctok($view) $ka] $tok] > 0} {
350
+ set ki $k
351
+ set tok [lindex $varctok($view) $ka]
352
+ }
353
+ }
354
+ set ka $varcid($view,$ki)
355
+ lappend vupptr($view) $ka
356
+ set i [lsearch -exact $parents($view,$ki) $id]
357
+ set j [expr {[llength $parents($view,$ki)] - 1 - $i}]
358
+ set rsib 0
359
+ while {[incr i] < [llength $parents($view,$ki)]} {
360
+ set bi [lindex $parents($view,$ki) $i]
361
+ if {[info exists varcid($view,$bi)]} {
362
+ set b $varcid($view,$bi)
363
+ if {[lindex $vupptr($view) $b] == $ka} {
364
+ set rsib $b
365
+ lappend vleftptr($view) [lindex $vleftptr($view) $b]
366
+ lset vleftptr($view) $b $a
367
+ break
368
+ }
369
+ }
370
+ }
371
+ if {$rsib == 0} {
372
+ lappend vleftptr($view) [lindex $vdownptr($view) $ka]
373
+ lset vdownptr($view) $ka $a
374
+ }
375
+ append tok [strrep $j]
376
+ }
377
+ lappend varctok($view) $tok
378
+ lappend varcstart($view) $id
379
+ lappend vdownptr($view) 0
380
+ lappend varcrow($view) {}
381
+ lappend varcix($view) {}
382
+ return $a
383
+}
384
+
385
+proc splitvarc {p v} {
386
+ global varcid varcstart varccommits varctok
387
+ global vupptr vdownptr vleftptr varcix varcrow
388
+
389
+ set oa $varcid($v,$p)
390
+ set ac $varccommits($v,$oa)
391
+ set i [lsearch -exact $varccommits($v,$oa) $p]
392
+ if {$i <= 0} return
393
+ set na [llength $varctok($v)]
394
+ # "%" sorts before "0"...
395
+ set tok "[lindex $varctok($v) $oa]%[strrep $i]"
396
+ lappend varctok($v) $tok
397
+ lappend varcrow($v) {}
398
+ lappend varcix($v) {}
399
+ set varccommits($v,$oa) [lrange $ac 0 [expr {$i - 1}]]
400
+ set varccommits($v,$na) [lrange $ac $i end]
401
+ lappend varcstart($v) $p
402
+ foreach id $varccommits($v,$na) {
403
+ set varcid($v,$id) $na
404
+ }
405
+ lappend vdownptr($v) [lindex $vdownptr($v) $oa]
406
+ lset vdownptr($v) $oa $na
407
+ lappend vupptr($v) $oa
408
+ lappend vleftptr($v) 0
409
+ for {set b [lindex $vdownptr($v) $na]} {$b != 0} {set b [lindex $vleftptr($v) $b]} {
410
+ lset vupptr($v) $b $na
411
+ }
412
+}
413
+
414
+proc renumbervarc {a v} {
415
+ global parents children varctok varcstart varccommits
416
+ global vupptr vdownptr vleftptr varcid vtokmod varcmod
417
+
418
+ set t1 [clock clicks -milliseconds]
419
+ set todo {}
420
+ set isrelated($a) 1
421
+ set ntot 0
422
+ while {$a != 0} {
423
+ if {[info exists isrelated($a)]} {
424
+ lappend todo $a
425
+ set id [lindex $varccommits($v,$a) end]
426
+ foreach p $parents($v,$id) {
427
+ if {[info exists varcid($v,$p)]} {
428
+ set isrelated($varcid($v,$p)) 1
429
+ }
430
+ }
431
+ }
432
+ incr ntot
433
+ set b [lindex $vdownptr($v) $a]
434
+ if {$b == 0} {
435
+ while {$a != 0} {
436
+ set b [lindex $vleftptr($v) $a]
437
+ if {$b != 0} break
438
+ set a [lindex $vupptr($v) $a]
439
+ }
440
+ }
441
+ set a $b
442
+ }
443
+ foreach a $todo {
444
+ set id [lindex $varcstart($v) $a]
445
+ set tok {}
446
+ foreach k $children($v,$id) {
447
+ set ka $varcid($v,$k)
448
+ if {[string compare [lindex $varctok($v) $ka] $tok] > 0} {
449
+ set ki $k
450
+ set tok [lindex $varctok($v) $ka]
451
+ }
452
+ }
453
+ if {$tok ne {}} {
454
+ set ka $varcid($v,$ki)
455
+ set i [lsearch -exact $parents($v,$ki) $id]
456
+ set j [expr {[llength $parents($v,$ki)] - 1 - $i}]
457
+ append tok [strrep $j]
458
+ set oldtok [lindex $varctok($v) $a]
459
+ if {$tok eq $oldtok} continue
460
+ lset varctok($v) $a $tok
461
+ } else {
462
+ set ka 0
463
+ }
464
+ set b [lindex $vupptr($v) $a]
465
+ if {$b != $ka} {
466
+ set c [lindex $vdownptr($v) $b]
467
+ if {$c == $a} {
468
+ lset vdownptr($v) $b [lindex $vleftptr($v) $a]
469
+ } else {
470
+ set b $c
471
+ while {$b != 0 && [lindex $vleftptr($v) $b] != $a} {
472
+ set b [lindex $vleftptr($v) $b]
473
+ }
474
+ if {$b != 0} {
475
+ lset vleftptr($v) $b [lindex $vleftptr($v) $a]
476
+ } else {
477
+ puts "oops couldn't find $a in chain for [lindex $vupptr($v) $a]"
478
+ }
479
+ }
480
+ lset vupptr($v) $a $ka
481
+ set rsib 0
482
+ while {[incr i] < [llength $parents($v,$ki)]} {
483
+ set bi [lindex $parents($v,$ki) $i]
484
+ if {[info exists varcid($v,$bi)]} {
485
+ set b $varcid($v,$bi)
486
+ if {[lindex $vupptr($v) $b] == $ka} {
487
+ set rsib $b
488
+ lset vleftptr($v) $a [lindex $vleftptr($v) $b]
489
+ lset vleftptr($v) $b $a
490
+ break
491
+ }
492
+ }
493
+ }
494
+ if {$rsib == 0} {
495
+ lset vleftptr($v) $a [lindex $vdownptr($v) $ka]
496
+ lset vdownptr($v) $ka $a
497
+ }
498
+ }
499
+ }
500
+ set t2 [clock clicks -milliseconds]
501
+ #puts "renumbervarc did [llength $todo] of $ntot arcs in [expr {$t2-$t1}]ms"
502
+}
503
+
504
+proc fix_reversal {p a v} {
505
+ global varcid varcstart varctok vupptr vseeds
506
+
507
+ set pa $varcid($v,$p)
508
+ if {$p ne [lindex $varcstart($v) $pa]} {
509
+ splitvarc $p $v
510
+ set pa $varcid($v,$p)
511
+ }
512
+ # seeds always need to be renumbered (and taken out of the seeds list)
513
+ if {[lindex $vupptr($v) $pa] == 0} {
514
+ set i [lsearch -exact $vseeds($v) $p]
515
+ if {$i >= 0} {
516
+ set vseeds($v) [lreplace $vseeds($v) $i $i]
517
+ } else {
518
+ puts "oops couldn't find [shortids $p] in seeds"
519
+ }
520
+ renumbervarc $pa $v
521
+ } elseif {[string compare [lindex $varctok($v) $a] \
522
+ [lindex $varctok($v) $pa]] > 0} {
523
+ renumbervarc $pa $v
524
+ }
525
+}
526
+
527
+proc insertrow {id p v} {
528
+ global varcid varccommits parents children cmitlisted ordertok
529
+ global commitidx varctok vtokmod varcmod
530
+
531
+ set a $varcid($v,$p)
532
+ set i [lsearch -exact $varccommits($v,$a) $p]
533
+ if {$i < 0} {
534
+ puts "oops: insertrow can't find [shortids $p] on arc $a"
535
+ return
536
+ }
537
+ set children($v,$id) {}
538
+ set parents($v,$id) [list $p]
539
+ set varcid($v,$id) $a
540
+ if {[llength [lappend children($v,$p) $id]] > 1 &&
541
+ [vtokcmp $v [lindex $children($v,$p) end-1] $id] > 0} {
542
+ set children($v,$p) [lsort -command [list vtokcmp $v] $children($v,$p)]
543
+ }
544
+ set cmitlisted($v,$id) 1
545
+ incr commitidx($v)
546
+ set ordertok($v,$id) $ordertok($v,$p)
547
+ # note we deliberately don't update varcstart($v) even if $i == 0
548
+ set varccommits($v,$a) [linsert $varccommits($v,$a) $i $id]
549
+ set tok [lindex $varctok($v) $a]
550
+ if {[string compare $tok $vtokmod($v)] < 0} {
551
+ set vtokmod($v) $tok
552
+ set varcmod($v) $a
553
+ }
554
+ update_arcrows $v
555
+}
556
+
557
+proc removerow {id v} {
558
+ global varcid varccommits parents children commitidx ordertok
559
+ global varctok vtokmod varcmod
560
+
561
+ if {[llength $parents($v,$id)] != 1} {
562
+ puts "oops: removerow [shortids $id] has [llength $parents($v,$id)] parents"
563
+ return
564
+ }
565
+ set p [lindex $parents($v,$id) 0]
566
+ set a $varcid($v,$id)
567
+ set i [lsearch -exact $varccommits($v,$a) $id]
568
+ if {$i < 0} {
569
+ puts "oops: removerow can't find [shortids $id] on arc $a"
570
+ return
571
+ }
572
+ unset varcid($v,$id)
573
+ set varccommits($v,$a) [lreplace $varccommits($v,$a) $i $i]
574
+ unset parents($v,$id)
575
+ unset children($v,$id)
576
+ unset cmitlisted($v,$id)
577
+ unset ordertok($v,$id)
578
+ incr commitidx($v) -1
579
+ set j [lsearch -exact $children($v,$p) $id]
580
+ if {$j >= 0} {
581
+ set children($v,$p) [lreplace $children($v,$p) $j $j]
582
+ }
583
+ set tok [lindex $varctok($v) $a]
584
+ if {[string compare $tok $vtokmod($v)] < 0} {
585
+ set vtokmod($v) $tok
586
+ set varcmod($v) $a
587
+ }
588
+ update_arcrows $v
589
+}
590
+
591
+proc vtokcmp {v a b} {
592
+ global varctok varcid
593
+
594
+ return [string compare [lindex $varctok($v) $varcid($v,$a)] \
595
+ [lindex $varctok($v) $varcid($v,$b)]]
596
+}
597
+
598
+proc update_arcrows {v} {
599
+ global vtokmod varcmod varcrow commitidx currentid selectedline
600
+ global varcid vseeds vrownum varcorder varcix varccommits
601
+ global vupptr vdownptr vleftptr varctok
602
+ global uat displayorder parentlist curview cached_commitrow
603
+
604
+ set t1 [clock clicks -milliseconds]
605
+ set narctot [expr {[llength $varctok($v)] - 1}]
606
+ set a $varcmod($v)
607
+ while {$a != 0 && [lindex $varcix($v) $a] eq {}} {
608
+ # go up the tree until we find something that has a row number,
609
+ # or we get to a seed
610
+ set a [lindex $vupptr($v) $a]
611
+ }
612
+ if {$a == 0} {
613
+ set a [lindex $vdownptr($v) 0]
614
+ if {$a == 0} return
615
+ set vrownum($v) {0}
616
+ set varcorder($v) [list $a]
617
+ lset varcix($v) $a 0
618
+ lset varcrow($v) $a 0
619
+ set arcn 0
620
+ set row 0
621
+ } else {
622
+ set arcn [lindex $varcix($v) $a]
623
+ # see if a is the last arc; if so, nothing to do
624
+ if {$arcn == $narctot - 1} {
625
+ return
626
+ }
627
+ if {[llength $vrownum($v)] > $arcn + 1} {
628
+ set vrownum($v) [lrange $vrownum($v) 0 $arcn]
629
+ set varcorder($v) [lrange $varcorder($v) 0 $arcn]
630
+ }
631
+ set row [lindex $varcrow($v) $a]
632
+ }
633
+ if {[llength $displayorder] > $row} {
634
+ set displayorder [lrange $displayorder 0 [expr {$row - 1}]]
635
+ set parentlist [lrange $parentlist 0 [expr {$row - 1}]]
636
+ }
637
+ if {$v == $curview} {
638
+ catch {unset cached_commitrow}
639
+ }
640
+ set startrow $row
641
+ while {1} {
642
+ set p $a
643
+ incr row [llength $varccommits($v,$a)]
644
+ # go down if possible
645
+ set b [lindex $vdownptr($v) $a]
646
+ if {$b == 0} {
647
+ # if not, go left, or go up until we can go left
648
+ while {$a != 0} {
649
+ set b [lindex $vleftptr($v) $a]
650
+ if {$b != 0} break
651
+ set a [lindex $vupptr($v) $a]
652
+ }
653
+ if {$a == 0} break
654
+ }
655
+ set a $b
656
+ incr arcn
657
+ lappend vrownum($v) $row
658
+ lappend varcorder($v) $a
659
+ lset varcix($v) $a $arcn
660
+ lset varcrow($v) $a $row
661
+ }
662
+ if {[info exists currentid]} {
663
+ set selectedline [rowofcommit $currentid]
664
+ }
665
+ undolayout $startrow
666
+ if {$row != $commitidx($v)} {
667
+ puts "oops update_arcrows got to row $row out of $commitidx($v)"
668
+ set vtokmod($v) {}
669
+ set varcmod($v) 0
670
+ } else {
671
+ set vtokmod($v) [lindex $varctok($v) $p]
672
+ set varcmod($v) $p
673
+ }
674
+ set t2 [clock clicks -milliseconds]
675
+ incr uat [expr {$t2-$t1}]
676
+}
677
+
678
+# Test whether view $v contains commit $id
679
+proc commitinview {id v} {
680
+ global varcid
681
+
682
+ return [info exists varcid($v,$id)]
683
+}
684
+
685
+# Return the row number for commit $id in the current view
686
+proc rowofcommit {id} {
687
+ global varcid varccommits varcrow curview cached_commitrow
688
+
689
+ if {[info exists cached_commitrow($id)]} {
690
+ return $cached_commitrow($id)
691
+ }
692
+ set v $curview
693
+ if {![info exists varcid($v,$id)]} {
694
+ puts "oops rowofcommit no arc for [shortids $id]"
695
+ return {}
696
+ }
697
+ set a $varcid($v,$id)
698
+ set i [lsearch -exact $varccommits($v,$a) $id]
699
+ if {$i < 0} {
700
+ puts "oops didn't find commit [shortids $id] in arc $a"
701
+ return {}
702
+ }
703
+ incr i [lindex $varcrow($v) $a]
704
+ set cached_commitrow($id) $i
705
+ return $i
706
+}
707
+
708
+proc bsearch {l elt} {
709
+ if {[llength $l] == 0 || $elt <= [lindex $l 0]} {
710
+ return 0
711
+ }
712
+ set lo 0
713
+ set hi [llength $l]
714
+ while {$hi - $lo > 1} {
715
+ set mid [expr {int(($lo + $hi) / 2)}]
716
+ set t [lindex $l $mid]
717
+ if {$elt < $t} {
718
+ set hi $mid
719
+ } elseif {$elt > $t} {
720
+ set lo $mid
721
+ } else {
722
+ return $mid
723
+ }
724
+ }
725
+ return $lo
726
+}
727
+
728
+# Make sure rows $start..$end-1 are valid in displayorder and parentlist
729
+proc make_disporder {start end} {
730
+ global vrownum curview commitidx displayorder parentlist
731
+ global varccommits varcorder parents
732
+ global d_valid_start d_valid_end
733
+
734
+ set ai [bsearch $vrownum($curview) $start]
735
+ set start [lindex $vrownum($curview) $ai]
736
+ set narc [llength $vrownum($curview)]
737
+ for {set r $start} {$ai < $narc && $r < $end} {incr ai} {
738
+ set a [lindex $varcorder($curview) $ai]
739
+ set l [llength $displayorder]
740
+ set al [llength $varccommits($curview,$a)]
741
+ if {$l < $r + $al} {
742
+ if {$l < $r} {
743
+ set pad [ntimes [expr {$r - $l}] {}]
744
+ set displayorder [concat $displayorder $pad]
745
+ set parentlist [concat $parentlist $pad]
746
+ } elseif {$l > $r} {
747
+ set displayorder [lrange $displayorder 0 [expr {$r - 1}]]
748
+ set parentlist [lrange $parentlist 0 [expr {$r - 1}]]
749
+ }
750
+ foreach id $varccommits($curview,$a) {
751
+ lappend displayorder $id
752
+ lappend parentlist $parents($curview,$id)
753
+ }
754
+ } elseif {[lindex $displayorder $r] eq {}} {
755
+ set i $r
756
+ foreach id $varccommits($curview,$a) {
757
+ lset displayorder $i $id
758
+ lset parentlist $i $parents($curview,$id)
759
+ incr i
760
+ }
761
+ }
762
+ incr r $al
763
+ }
764
+}
765
+
766
+proc commitonrow {row} {
767
+ global displayorder
768
+
769
+ set id [lindex $displayorder $row]
770
+ if {$id eq {}} {
771
+ make_disporder $row [expr {$row + 1}]
772
+ set id [lindex $displayorder $row]
773
+ }
774
+ return $id
775
+}
776
+
777
+proc closevarcs {v} {
778
+ global varctok varccommits varcid parents children
779
+ global cmitlisted commitidx commitinterest vtokmod varcmod
780
+
781
+ set missing_parents 0
782
+ set scripts {}
783
+ set narcs [llength $varctok($v)]
784
+ for {set a 1} {$a < $narcs} {incr a} {
785
+ set id [lindex $varccommits($v,$a) end]
786
+ foreach p $parents($v,$id) {
787
+ if {[info exists varcid($v,$p)]} continue
788
+ # add p as a new commit
789
+ incr missing_parents
790
+ set cmitlisted($v,$p) 0
791
+ set parents($v,$p) {}
792
+ if {[llength $children($v,$p)] == 1 &&
793
+ [llength $parents($v,$id)] == 1} {
794
+ set b $a
795
+ } else {
796
+ set b [newvarc $v $p]
797
+ }
798
+ set varcid($v,$p) $b
799
+ lappend varccommits($v,$b) $p
800
+ set tok [lindex $varctok($v) $b]
801
+ if {[string compare $tok $vtokmod($v)] < 0} {
802
+ set vtokmod($v) $tok
803
+ set varcmod($v) $b
804
+ }
805
+ incr commitidx($v)
806
+ if {[info exists commitinterest($p)]} {
807
+ foreach script $commitinterest($p) {
808
+ lappend scripts [string map [list "%I" $p] $script]
809
+ }
810
+ unset commitinterest($id)
811
+ }
812
+ }
813
+ }
814
+ if {$missing_parents > 0} {
815
+ update_arcrows $v
816
+ foreach s $scripts {
817
+ eval $s
818
+ }
819
+ }
820
+}
821
+
822
+proc getcommitlines {fd inst view} {
823
+ global cmitlisted commitinterest leftover getdbg
824
+ global commitidx commitdata
825
+ global parents children curview hlview
826
global ordertok vnextroot idpending
827
+ global varccommits varcid varctok vtokmod varcmod
828
829
set stuff [read $fd 500000]
830
# git log doesn't terminate the last commit with a null...
167
- if {$stuff == {} && $leftover($view) ne {} && [eof $fd]} {
831
+ if {$stuff == {} && $leftover($inst) ne {} && [eof $fd]} {
832
set stuff "\0"
833
}
834
if {$stuff == {}} {
835
if {![eof $fd]} {
836
return 1
837
}
174
- # Check if we have seen any ids listed as parents that haven't
175
- # appeared in the list
176
- foreach vid [array names idpending "$view,*"] {
177
- # should only get here if git log is buggy
178
- set id [lindex [split $vid ","] 1]
179
- set commitrow($vid) $commitidx($view)
180
- incr commitidx($view)
181
- if {$view == $curview} {
182
- lappend parentlist {}
183
- lappend displayorder $id
184
- lappend commitlisted 0
185
- } else {
186
- lappend vparentlist($view) {}
187
- lappend vdisporder($view) $id
188
- lappend vcmitlisted($view) 0
189
- }
838
+ global commfd viewcomplete viewactive viewname progresscoords
839
+ global viewinstances
840
+ unset commfd($inst)
841
+ set i [lsearch -exact $viewinstances($view) $inst]
842
+ if {$i >= 0} {
843
+ set viewinstances($view) [lreplace $viewinstances($view) $i $i]
844
}
191
- set viewcomplete($view) 1
192
- global viewname progresscoords
193
- unset commfd($view)
194
- notbusy $view
195
- set progresscoords {0 0}
196
- adjustprogress
845
# set it blocking so we wait for the process to terminate
846
fconfigure $fd -blocking 1
847
if {[catch {close $fd} err]} {
862
}
863
error_popup $err
864
}
865
+ if {[incr viewactive($view) -1] <= 0} {
866
+ set viewcomplete($view) 1
867
+ # Check if we have seen any ids listed as parents that haven't
868
+ # appeared in the list
869
+ closevarcs $view
870
+ notbusy $view
871
+ set progresscoords {0 0}
872
+ adjustprogress
873
+ }
874
if {$view == $curview} {
875
run chewcommits $view
876
}
878
}
879
set start 0
880
set gotsome 0
881
+ set scripts {}
882
while 1 {
883
set i [string first "\0" $stuff $start]
884
if {$i < 0} {
227
- append leftover($view) [string range $stuff $start end]
885
+ append leftover($inst) [string range $stuff $start end]
886
break
887
}
888
if {$start == 0} {
231
- set cmit $leftover($view)
889
+ set cmit $leftover($inst)
890
append cmit [string range $stuff 0 [expr {$i - 1}]]
233
- set leftover($view) {}
891
+ set leftover($inst) {}
892
} else {
893
set cmit [string range $stuff $start [expr {$i - 1}]]
894
}
923
exit 1
924
}
925
set id [lindex $ids 0]
268
- if {![info exists ordertok($view,$id)]} {
926
+ set vid $view,$id
927
+ if {!$listed && [info exists parents($vid)]} continue
928
+ if {![info exists ordertok($vid)]} {
929
set otok "o[strrep $vnextroot($view)]"
930
incr vnextroot($view)
271
- set ordertok($view,$id) $otok
931
+ set ordertok($vid) $otok
932
} else {
273
- set otok $ordertok($view,$id)
274
- unset idpending($view,$id)
933
+ set otok $ordertok($vid)
934
}
935
if {$listed} {
936
set olds [lrange $ids 1 end]
937
if {[llength $olds] == 1} {
938
set p [lindex $olds 0]
280
- lappend children($view,$p) $id
939
if {![info exists ordertok($view,$p)]} {
282
- set ordertok($view,$p) $ordertok($view,$id)
283
- set idpending($view,$p) 1
940
+ set ordertok($view,$p) $ordertok($vid)
941
}
942
} else {
943
set i 0
944
foreach p $olds {
288
- if {$i == 0 || [lsearch -exact $olds $p] >= $i} {
289
- lappend children($view,$p) $id
290
- }
945
if {![info exists ordertok($view,$p)]} {
946
set ordertok($view,$p) "$otok[strrep $i]]"
293
- set idpending($view,$p) 1
947
}
948
incr i
949
}
951
} else {
952
set olds {}
953
}
301
- if {![info exists children($view,$id)]} {
302
- set children($view,$id) {}
303
- }
954
set commitdata($id) [string range $cmit [expr {$j + 1}] end]
305
- set commitrow($view,$id) $commitidx($view)
306
- incr commitidx($view)
307
- if {$view == $curview} {
308
- lappend parentlist $olds
309
- lappend displayorder $id
310
- lappend commitlisted $listed
955
+ set cmitlisted($vid) $listed
956
+ set parents($vid) $olds
957
+ set a 0
958
+ if {![info exists children($vid)]} {
959
+ set children($vid) {}
960
} else {
312
- lappend vparentlist($view) $olds
313
- lappend vdisporder($view) $id
314
- lappend vcmitlisted($view) $listed
961
+ if {[llength $children($vid)] == 1} {
962
+ set k [lindex $children($vid) 0]
963
+ if {[llength $parents($view,$k)] == 1} {
964
+ set a $varcid($view,$k)
965
+ }
966
+ }
967
}
968
+ if {$a == 0} {
969
+ # new arc
970
+ set a [newvarc $view $id]
971
+ }
972
+ set varcid($vid) $a
973
+ lappend varccommits($view,$a) $id
974
+ set tok [lindex $varctok($view) $a]
975
+ set i 0
976
+ foreach p $olds {
977
+ if {$i == 0 || [lsearch -exact $olds $p] >= $i} {
978
+ set vp $view,$p
979
+ if {[llength [lappend children($vp) $id]] > 1 &&
980
+ [vtokcmp $view [lindex $children($vp) end-1] $id] > 0} {
981
+ set children($vp) [lsort -command [list vtokcmp $view] \
982
+ $children($vp)]
983
+ }
984
+ }
985
+ if {[info exists varcid($view,$p)]} {
986
+ fix_reversal $p $a $view
987
+ }
988
+ incr i
989
+ }
990
+ if {[string compare $tok $vtokmod($view)] < 0} {
991
+ set vtokmod($view) $tok
992
+ set varcmod($view) $a
993
+ }
994
+
995
+ incr commitidx($view)
996
if {[info exists commitinterest($id)]} {
997
foreach script $commitinterest($id) {
318
- eval [string map [list "%I" $id] $script]
998
+ lappend scripts [string map [list "%I" $id] $script]
999
}
1000
unset commitinterest($id)
1001
}
1002
set gotsome 1
1003
}
1004
if {$gotsome} {
1005
+ update_arcrows $view
1006
run chewcommits $view
1007
+ foreach s $scripts {
1008
+ eval $s
1009
+ }
1010
if {$view == $curview} {
1011
# update progress bar
1012
global progressdirn progresscoords proglastnc
1040
1041
proc chewcommits {view} {
1042
global curview hlview viewcomplete
359
- global selectedline pending_select
1043
+ global pending_select
1044
1045
if {$view == $curview} {
1046
layoutmore
1047
if {$viewcomplete($view)} {
364
- global displayorder commitidx phase
1048
+ global commitidx
1049
global numcommits startmsecs
1050
+ global mainheadid commitinfo nullid
1051
1052
if {[info exists pending_select]} {
1053
set row [first_real_row]
1056
if {$commitidx($curview) > 0} {
1057
#set ms [expr {[clock clicks -milliseconds] - $startmsecs}]
1058
#puts "overall $ms ms for $numcommits commits"
1059
+ #global uat
1060
+ #puts "${uat}ms in update_arcrows"
1061
} else {
1062
show_status "No commits selected"
1063
}
1064
notbusy layout
378
- set phase {}
1065
}
1066
}
1067
if {[info exists hlview] && $view == $hlview} {
1075
parsecommit $id $contents 0
1076
}
1077
392
-proc updatecommits {} {
393
- global viewdata curview phase displayorder ordertok idpending
394
- global children commitrow selectedline thickerline showneartags
395
-
396
- if {$phase ne {}} {
397
- stop_rev_list
398
- set phase {}
399
- }
400
- set n $curview
401
- foreach id $displayorder {
402
- catch {unset children($n,$id)}
403
- catch {unset commitrow($n,$id)}
404
- catch {unset ordertok($n,$id)}
405
- }
406
- foreach vid [array names idpending "$n,*"] {
407
- unset idpending($vid)
408
- }
409
- set curview -1
410
- catch {unset selectedline}
411
- catch {unset thickerline}
412
- catch {unset viewdata($n)}
413
- readrefs
414
- changedrefs
415
- if {$showneartags} {
416
- getallcommits
417
- }
418
- showview $n
419
-}
420
-
1078
proc parsecommit {id contents listed} {
1079
global commitinfo cdate
1080
1201
1202
# skip over fake commits
1203
proc first_real_row {} {
547
- global nullid nullid2 displayorder numcommits
1204
+ global nullid nullid2 numcommits
1205
1206
for {set row 0} {$row < $numcommits} {incr row} {
550
- set id [lindex $displayorder $row]
1207
+ set id [commitonrow $row]
1208
if {$id ne $nullid && $id ne $nullid2} {
1209
break
1210
}
1291
.bar configure -font uifont
1292
menu .bar.file
1293
.bar.file add command -label "Update" -command updatecommits
1294
+ .bar.file add command -label "Reload" -command reloadcommits
1295
.bar.file add command -label "Reread references" -command rereadrefs
1296
.bar.file add command -label "List references" -command showrefs
1297
.bar.file add command -label "Quit" -command doquit
2301
-data $rectdata -maskdata $rectmask
2302
2303
proc init_flist {first} {
1646
- global cflist cflist_top selectedline difffilestart
2304
+ global cflist cflist_top difffilestart
2305
2306
$cflist conf -state normal
2307
$cflist delete 0.0 end
2644
set viewfiles($n) $files
2645
set viewargs($n) $newargs
2646
if {$curview == $n} {
1989
- run updatecommits
2647
+ run reloadcommits
2648
}
2649
}
2650
}
2652
}
2653
2654
proc delview {} {
1997
- global curview viewdata viewperm hlview selectedhlview
2655
+ global curview viewperm hlview selectedhlview
2656
2657
if {$curview == 0} return
2658
if {[info exists hlview] && $hlview == $curview} {
2660
unset hlview
2661
}
2662
allviewmenus $curview delete
2005
- set viewdata($curview) {}
2663
set viewperm($curview) 0
2664
showview 0
2665
}
2673
# -command [list addvhighlight $n] -variable selectedhlview
2674
}
2675
2019
-proc flatten {var} {
2020
- global $var
2021
-
2022
- set ret {}
2023
- foreach i [array names $var] {
2024
- lappend ret $i [set $var\($i\)]
2025
- }
2026
- return $ret
2027
-}
2028
-
2029
-proc unflatten {var l} {
2030
- global $var
2031
-
2032
- catch {unset $var}
2033
- foreach {i v} $l {
2034
- set $var\($i\) $v
2035
- }
2036
-}
2037
-
2676
proc showview {n} {
2039
- global curview viewdata viewfiles
2677
+ global curview viewfiles cached_commitrow
2678
global displayorder parentlist rowidlist rowisopt rowfinal
2041
- global colormap rowtextx commitrow nextcolor canvxmax
2042
- global numcommits commitlisted
2679
+ global colormap rowtextx nextcolor canvxmax
2680
+ global numcommits viewcomplete
2681
global selectedline currentid canv canvy0
2682
global treediffs
2045
- global pending_select phase
2683
+ global pending_select
2684
global commitidx
2047
- global commfd
2685
global selectedview selectfirst
2049
- global vparentlist vdisporder vcmitlisted
2686
global hlview selectedhlview commitinterest
2687
2688
if {$n == $curview} return
2689
set selid {}
2690
+ set ymax [lindex [$canv cget -scrollregion] 3]
2691
+ set span [$canv yview]
2692
+ set ytop [expr {[lindex $span 0] * $ymax}]
2693
+ set ybot [expr {[lindex $span 1] * $ymax}]
2694
+ set yscreen [expr {($ybot - $ytop) / 2}]
2695
if {[info exists selectedline]} {
2696
set selid $currentid
2697
set y [yc $selectedline]
2057
- set ymax [lindex [$canv cget -scrollregion] 3]
2058
- set span [$canv yview]
2059
- set ytop [expr {[lindex $span 0] * $ymax}]
2060
- set ybot [expr {[lindex $span 1] * $ymax}]
2698
if {$ytop < $y && $y < $ybot} {
2699
set yscreen [expr {$y - $ytop}]
2063
- } else {
2064
- set yscreen [expr {($ybot - $ytop) / 2}]
2700
}
2701
} elseif {[info exists pending_select]} {
2702
set selid $pending_select
2704
}
2705
unselectline
2706
normalline
2072
- if {$curview >= 0} {
2073
- set vparentlist($curview) $parentlist
2074
- set vdisporder($curview) $displayorder
2075
- set vcmitlisted($curview) $commitlisted
2076
- if {$phase ne {} ||
2077
- ![info exists viewdata($curview)] ||
2078
- [lindex $viewdata($curview) 0] ne {}} {
2079
- set viewdata($curview) \
2080
- [list $phase $rowidlist $rowisopt $rowfinal]
2081
- }
2082
- }
2707
catch {unset treediffs}
2708
clear_display
2709
if {[info exists hlview] && $hlview == $n} {
2711
set selectedhlview None
2712
}
2713
catch {unset commitinterest}
2714
+ catch {unset cached_commitrow}
2715
2716
set curview $n
2717
set selectedview $n
2719
.bar.view entryconf Delete* -state [expr {$n == 0? "disabled": "normal"}]
2720
2721
run refill_reflist
2097
- if {![info exists viewdata($n)]} {
2722
+ if {![info exists viewcomplete($n)]} {
2723
if {$selid ne {}} {
2724
set pending_select $selid
2725
}
2727
return
2728
}
2729
2105
- set v $viewdata($n)
2106
- set phase [lindex $v 0]
2107
- set displayorder $vdisporder($n)
2108
- set parentlist $vparentlist($n)
2109
- set commitlisted $vcmitlisted($n)
2110
- set rowidlist [lindex $v 1]
2111
- set rowisopt [lindex $v 2]
2112
- set rowfinal [lindex $v 3]
2730
+ set displayorder {}
2731
+ set parentlist {}
2732
+ set rowidlist {}
2733
+ set rowisopt {}
2734
+ set rowfinal {}
2735
set numcommits $commitidx($n)
2736
2737
catch {unset colormap}
2744
set yf 0
2745
set row {}
2746
set selectfirst 0
2125
- if {$selid ne {} && [info exists commitrow($n,$selid)]} {
2126
- set row $commitrow($n,$selid)
2747
+ if {$selid ne {} && [commitinview $selid $n]} {
2748
+ set row [rowofcommit $selid]
2749
# try to get the selected row in the same position on the screen
2750
set ymax [lindex [$canv cget -scrollregion] 3]
2751
set ytop [expr {[yc $row] - $yscreen}]
2768
set selectfirst 1
2769
}
2770
}
2149
- if {$phase ne {}} {
2150
- if {$phase eq "getcommits"} {
2771
+ if {!$viewcomplete($n)} {
2772
+ if {$numcommits == 0} {
2773
show_status "Reading commits..."
2774
+ } else {
2775
+ run chewcommits $n
2776
}
2153
- run chewcommits $n
2777
} elseif {$numcommits == 0} {
2778
show_status "No commits selected"
2779
}
2842
}
2843
2844
proc addvhighlight {n} {
2222
- global hlview curview viewdata vhl_done vhighlights commitidx
2845
+ global hlview viewcomplete curview vhl_done vhighlights commitidx
2846
2847
if {[info exists hlview]} {
2848
delvhighlight
2849
}
2850
set hlview $n
2228
- if {$n != $curview && ![info exists viewdata($n)]} {
2229
- set viewdata($n) [list getcommits {{}} 0 0 0]
2230
- set vparentlist($n) {}
2231
- set vdisporder($n) {}
2232
- set vcmitlisted($n) {}
2851
+ if {$n != $curview && ![info exists viewcomplete($n)]} {
2852
start_rev_list $n
2853
}
2854
set vhl_done $commitidx($hlview)
2867
}
2868
2869
proc vhighlightmore {} {
2251
- global hlview vhl_done commitidx vhighlights
2252
- global displayorder vdisporder curview
2870
+ global hlview vhl_done commitidx vhighlights curview
2871
2872
set max $commitidx($hlview)
2255
- if {$hlview == $curview} {
2256
- set disp $displayorder
2257
- } else {
2258
- set disp $vdisporder($hlview)
2259
- }
2873
set vr [visiblerows]
2874
set r0 [lindex $vr 0]
2875
set r1 [lindex $vr 1]
2876
for {set i $vhl_done} {$i < $max} {incr i} {
2264
- set id [lindex $disp $i]
2265
- if {[info exists commitrow($curview,$id)]} {
2266
- set row $commitrow($curview,$id)
2877
+ set id [commitonrow $i $hlview]
2878
+ if {[commitinview $id $curview]} {
2879
+ set row [rowofcommit $id]
2880
if {$r0 <= $row && $row <= $r1} {
2881
if {![highlighted $row]} {
2882
bolden $row mainfontbold
2889
}
2890
2891
proc askvhighlight {row id} {
2279
- global hlview vhighlights commitrow iddrawn
2892
+ global hlview vhighlights iddrawn
2893
2281
- if {[info exists commitrow($hlview,$id)]} {
2894
+ if {[commitinview $id $hlview]} {
2895
if {[info exists iddrawn($id)] && ![ishighlighted $row]} {
2896
bolden $row mainfontbold
2897
}
3040
}
3041
3042
proc readfhighlight {} {
2430
- global filehighlight fhighlights commitrow curview iddrawn
3043
+ global filehighlight fhighlights curview iddrawn
3044
global fhl_list find_dirn
3045
3046
if {![info exists filehighlight]} {
3053
if {$i < 0} continue
3054
for {set j 0} {$j < $i} {incr j} {
3055
set id [lindex $fhl_list $j]
2443
- if {[info exists commitrow($curview,$id)]} {
2444
- set fhighlights($commitrow($curview,$id)) 0
3056
+ if {[commitinview $id $curview]} {
3057
+ set fhighlights([rowofcommit $id]) 0
3058
}
3059
}
3060
set fhl_list [lrange $fhl_list [expr {$i+1}] end]
3061
if {$line eq {}} continue
2449
- if {![info exists commitrow($curview,$line)]} continue
2450
- set row $commitrow($curview,$line)
3062
+ if {![commitinview $line $curview]} continue
3063
+ set row [rowofcommit $line]
3064
if {[info exists iddrawn($line)] && ![ishighlighted $row]} {
3065
bolden $row mainfontbold
3066
}
3181
}
3182
3183
proc is_descendent {a} {
2571
- global curview children commitrow descendent desc_todo
3184
+ global curview children descendent desc_todo
3185
3186
set v $curview
2574
- set la $commitrow($v,$a)
3187
+ set la [rowofcommit $a]
3188
set todo $desc_todo
3189
set leftover {}
3190
set done 0
3191
for {set i 0} {$i < [llength $todo]} {incr i} {
3192
set do [lindex $todo $i]
2580
- if {$commitrow($v,$do) < $la} {
3193
+ if {[rowofcommit $do] < $la} {
3194
lappend leftover $do
3195
continue
3196
}
3213
}
3214
3215
proc is_ancestor {a} {
2603
- global curview parentlist commitrow ancestor anc_todo
3216
+ global curview parents ancestor anc_todo
3217
3218
set v $curview
2606
- set la $commitrow($v,$a)
3219
+ set la [rowofcommit $a]
3220
set todo $anc_todo
3221
set leftover {}
3222
set done 0
3223
for {set i 0} {$i < [llength $todo]} {incr i} {
3224
set do [lindex $todo $i]
2612
- if {![info exists commitrow($v,$do)] || $commitrow($v,$do) > $la} {
3225
+ if {![commitinview $do $v] || [rowofcommit $do] > $la} {
3226
lappend leftover $do
3227
continue
3228
}
2616
- foreach np [lindex $parentlist $commitrow($v,$do)] {
3229
+ foreach np $parents($v,$do) {
3230
if {![info exists ancestor($np)]} {
3231
set ancestor($np) 1
3232
lappend todo $np
3327
}
3328
3329
proc initlayout {} {
2717
- global rowidlist rowisopt rowfinal displayorder commitlisted
3330
+ global rowidlist rowisopt rowfinal displayorder parentlist
3331
global numcommits canvxmax canv
3332
global nextcolor
2720
- global parentlist
3333
global colormap rowtextx
3334
global selectfirst
3335
3336
set numcommits 0
3337
set displayorder {}
2726
- set commitlisted {}
3338
set parentlist {}
3339
set nextcolor 0
3340
set rowidlist {}
3385
}
3386
3387
proc showstuff {canshow last} {
2777
- global numcommits commitrow pending_select selectedline curview
2778
- global mainheadid displayorder selectfirst
3388
+ global numcommits pending_select selectedline curview
3389
+ global selectfirst
3390
global lastscrollset commitinterest
3391
3392
if {$numcommits == 0} {
3411
drawcommits $r0 $r1
3412
}
3413
if {[info exists pending_select] &&
2803
- [info exists commitrow($curview,$pending_select)] &&
2804
- $commitrow($curview,$pending_select) < $numcommits} {
2805
- selectline $commitrow($curview,$pending_select) 1
3414
+ [commitinview $pending_select $curview]} {
3415
+ selectline [rowofcommit $pending_select] 1
3416
}
3417
if {$selectfirst} {
3418
if {[info exists selectedline] || [info exists pending_select]} {
3426
}
3427
3428
proc doshowlocalchanges {} {
2819
- global curview mainheadid phase commitrow
3429
+ global curview mainheadid phase
3430
2821
- if {[info exists commitrow($curview,$mainheadid)] &&
2822
- ($phase eq {} || $commitrow($curview,$mainheadid) < $numcommits - 1)} {
3431
+ if {[commitinview $mainheadid $curview]} {
3432
dodiffindex
3433
} elseif {$phase ne {}} {
3434
lappend commitinterest($mainheadid) {}
3436
}
3437
3438
proc dohidelocalchanges {} {
2830
- global localfrow localirow lserial
3439
+ global nullid nullid2 lserial curview
3440
2832
- if {$localfrow >= 0} {
2833
- removerow $localfrow
2834
- set localfrow -1
2835
- if {$localirow > 0} {
2836
- incr localirow -1
2837
- }
3441
+ if {[commitinview $nullid $curview]} {
3442
+ removerow $nullid $curview
3443
}
2839
- if {$localirow >= 0} {
2840
- removerow $localirow
2841
- set localirow -1
3444
+ if {[commitinview $nullid2 $curview]} {
3445
+ removerow $nullid2 $curview
3446
}
3447
incr lserial
3448
}
3449
3450
# spawn off a process to do git diff-index --cached HEAD
3451
proc dodiffindex {} {
2848
- global localirow localfrow lserial showlocalchanges
3452
+ global lserial showlocalchanges
3453
3454
if {!$showlocalchanges} return
3455
incr lserial
2852
- set localfrow -1
2853
- set localirow -1
3456
set fd [open "|git diff-index --cached HEAD" r]
3457
fconfigure $fd -blocking 0
3458
filerun $fd [list readdiffindex $fd $lserial]
3459
}
3460
3461
proc readdiffindex {fd serial} {
2860
- global localirow commitrow mainheadid nullid2 curview
2861
- global commitinfo commitdata lserial
3462
+ global mainheadid nullid2 curview commitinfo commitdata lserial
3463
3464
set isdiff 1
3465
if {[gets $fd line] < 0} {
3478
filerun $fd [list readdifffiles $fd $serial]
3479
}
3480
2880
- if {$isdiff && $serial == $lserial && $localirow == -1} {
3481
+ if {$isdiff && $serial == $lserial && ![commitinview $nullid2 $curview]} {
3482
# add the line for the changes in the index to the graph
2882
- set localirow $commitrow($curview,$mainheadid)
3483
set hl "Local changes checked in to index but not committed"
3484
set commitinfo($nullid2) [list $hl {} {} {} {} " $hl\n"]
3485
set commitdata($nullid2) "\n $hl\n"
2886
- insertrow $localirow $nullid2
3486
+ insertrow $nullid2 $mainheadid $curview
3487
}
3488
return 0
3489
}
3490
3491
proc readdifffiles {fd serial} {
2892
- global localirow localfrow commitrow mainheadid nullid curview
3492
+ global mainheadid nullid nullid2 curview
3493
global commitinfo commitdata lserial
3494
3495
set isdiff 1
3502
# we only need to see one line and we don't really care what it says...
3503
close $fd
3504
2905
- if {$isdiff && $serial == $lserial && $localfrow == -1} {
3505
+ if {$isdiff && $serial == $lserial && ![commitinview $nullid $curview]} {
3506
# add the line for the local diff to the graph
2907
- if {$localirow >= 0} {
2908
- set localfrow $localirow
2909
- incr localirow
2910
- } else {
2911
- set localfrow $commitrow($curview,$mainheadid)
2912
- }
3507
set hl "Local uncommitted changes, not checked in to index"
3508
set commitinfo($nullid) [list $hl {} {} {} {} " $hl\n"]
3509
set commitdata($nullid) "\n $hl\n"
2916
- insertrow $localfrow $nullid
3510
+ if {[commitinview $nullid2 $curview]} {
3511
+ set p $nullid2
3512
+ } else {
3513
+ set p $mainheadid
3514
+ }
3515
+ insertrow $nullid $p $curview
3516
}
3517
return 0
3518
}
3519
3520
proc nextuse {id row} {
2922
- global commitrow curview children
3521
+ global curview children
3522
3523
if {[info exists children($curview,$id)]} {
3524
foreach kid $children($curview,$id) {
2926
- if {![info exists commitrow($curview,$kid)]} {
3525
+ if {![commitinview $kid $curview]} {
3526
return -1
3527
}
2929
- if {$commitrow($curview,$kid) > $row} {
2930
- return $commitrow($curview,$kid)
3528
+ if {[rowofcommit $kid] > $row} {
3529
+ return [rowofcommit $kid]
3530
}
3531
}
3532
}
2934
- if {[info exists commitrow($curview,$id)]} {
2935
- return $commitrow($curview,$id)
3533
+ if {[commitinview $id $curview]} {
3534
+ return [rowofcommit $id]
3535
}
3536
return -1
3537
}
3538
3539
proc prevuse {id row} {
2941
- global commitrow curview children
3540
+ global curview children
3541
3542
set ret -1
3543
if {[info exists children($curview,$id)]} {
3544
foreach kid $children($curview,$id) {
2946
- if {![info exists commitrow($curview,$kid)]} break
2947
- if {$commitrow($curview,$kid) < $row} {
2948
- set ret $commitrow($curview,$kid)
3545
+ if {![commitinview $kid $curview]} break
3546
+ if {[rowofcommit $kid] < $row} {
3547
+ set ret [rowofcommit $kid]
3548
}
3549
}
3550
}
3553
3554
proc make_idlist {row} {
3555
global displayorder parentlist uparrowlen downarrowlen mingaplen
2957
- global commitidx curview ordertok children commitrow
3556
+ global commitidx curview ordertok children
3557
3558
set r [expr {$row - $mingaplen - $downarrowlen - 1}]
3559
if {$r < 0} {
3567
if {$rb > $commitidx($curview)} {
3568
set rb $commitidx($curview)
3569
}
3570
+ make_disporder $r [expr {$rb + 1}]
3571
set ids {}
3572
for {} {$r < $ra} {incr r} {
3573
set nextid [lindex $displayorder [expr {$r + 1}]]
3595
while {$r < $rb} {
3596
foreach p [lindex $parentlist $r] {
3597
set firstkid [lindex $children($curview,$p) 0]
2998
- if {$commitrow($curview,$firstkid) < $row} {
3598
+ if {[rowofcommit $firstkid] < $row} {
3599
lappend ids [list $ordertok($curview,$p) $p]
3600
}
3601
}
3603
set id [lindex $displayorder $r]
3604
if {$id ne {}} {
3605
set firstkid [lindex $children($curview,$id) 0]
3006
- if {$firstkid ne {} && $commitrow($curview,$firstkid) < $row} {
3606
+ if {$firstkid ne {} && [rowofcommit $firstkid] < $row} {
3607
lappend ids [list $ordertok($curview,$id) $id]
3608
}
3609
}
3650
global rowidlist rowisopt rowfinal displayorder
3651
global uparrowlen downarrowlen maxwidth mingaplen
3652
global children parentlist
3053
- global commitidx viewcomplete curview commitrow
3653
+ global commitidx viewcomplete curview
3654
3655
+ make_disporder [expr {$row - 1}] [expr {$endrow + $uparrowlen}]
3656
set idlist {}
3657
if {$row > 0} {
3658
set rm1 [expr {$row - 1}]
3708
foreach p [lindex $parentlist $r] {
3709
if {[lsearch -exact $idlist $p] >= 0} continue
3710
set fk [lindex $children($curview,$p) 0]
3110
- if {$commitrow($curview,$fk) < $row} {
3711
+ if {[rowofcommit $fk] < $row} {
3712
set x [idcol $idlist $p $x]
3713
set idlist [linsert $idlist $x $p]
3714
}
3717
set p [lindex $displayorder $r]
3718
if {[lsearch -exact $idlist $p] < 0} {
3719
set fk [lindex $children($curview,$p) 0]
3119
- if {$fk ne {} && $commitrow($curview,$fk) < $row} {
3720
+ if {$fk ne {} && [rowofcommit $fk] < $row} {
3721
set x [idcol $idlist $p $x]
3722
set idlist [linsert $idlist $x $p]
3723
}
3932
}
3933
3934
proc rowranges {id} {
3334
- global commitrow curview children uparrowlen downarrowlen
3935
+ global curview children uparrowlen downarrowlen
3936
global rowidlist
3937
3938
set kids $children($curview,$id)
3942
set ret {}
3943
lappend kids $id
3944
foreach child $kids {
3344
- if {![info exists commitrow($curview,$child)]} break
3345
- set row $commitrow($curview,$child)
3945
+ if {![commitinview $child $curview]} break
3946
+ set row [rowofcommit $child]
3947
if {![info exists prev]} {
3948
lappend ret [expr {$row + 1}]
3949
} else {
3950
if {$row <= $prevrow} {
3350
- puts "oops children out of order [shortids $id] $row < [shortids $prev] $prevrow"
3951
+ puts "oops children of [shortids $id] out of order [shortids $child] $row <= [shortids $prev] $prevrow"
3952
}
3953
# see if the line extends the whole way from prevrow to row
3954
if {$row > $prevrow + $uparrowlen + $downarrowlen &&
3981
if {$child eq $id} {
3982
lappend ret $row
3983
}
3383
- set prev $id
3984
+ set prev $child
3985
set prevrow $row
3986
}
3987
return $ret
4229
}
4230
4231
proc drawcmittext {id row col} {
3631
- global linespc canv canv2 canv3 canvy0 fgcolor curview
3632
- global commitlisted commitinfo rowidlist parentlist
4232
+ global linespc canv canv2 canv3 fgcolor curview
4233
+ global cmitlisted commitinfo rowidlist parentlist
4234
global rowtextx idpos idtags idheads idotherrefs
4235
global linehtag linentag linedtag selectedline
4236
global canvxmax boldrows boldnamerows fgcolor nullid nullid2
4237
4238
# listed is 0 for boundary, 1 for normal, 2 for left, 3 for right
3638
- set listed [lindex $commitlisted $row]
4239
+ set listed $cmitlisted($curview,$id)
4240
if {$id eq $nullid} {
4241
set ofill red
4242
} elseif {$id eq $nullid2} {
4321
proc drawcmitrow {row} {
4322
global displayorder rowidlist nrows_drawn
4323
global iddrawn markingmatches
3723
- global commitinfo parentlist numcommits
4324
+ global commitinfo numcommits
4325
global filehighlight fhighlights findpattern nhighlights
4326
global hlview vhighlights
4327
global highlight_related rhighlights
4441
}
4442
}
4443
4444
+proc undolayout {row} {
4445
+ global uparrowlen mingaplen downarrowlen
4446
+ global rowidlist rowisopt rowfinal need_redisplay
4447
+
4448
+ set r [expr {$row - ($uparrowlen + $mingaplen + $downarrowlen)}]
4449
+ if {$r < 0} {
4450
+ set r 0
4451
+ }
4452
+ if {[llength $rowidlist] > $r} {
4453
+ incr r -1
4454
+ set rowidlist [lrange $rowidlist 0 $r]
4455
+ set rowfinal [lrange $rowfinal 0 $r]
4456
+ set rowisopt [lrange $rowisopt 0 $r]
4457
+ set need_redisplay 1
4458
+ run drawvisible
4459
+ }
4460
+}
4461
+
4462
proc drawfrac {f0 f1} {
4463
global canv linespc
4464
4528
4529
proc assigncolor {id} {
4530
global colormap colors nextcolor
3912
- global commitrow parentlist children children curview
4531
+ global parents children children curview
4532
4533
if {[info exists colormap($id)]} return
4534
set ncolors [llength $colors]
4540
if {[llength $kids] == 1} {
4541
set child [lindex $kids 0]
4542
if {[info exists colormap($child)]
3924
- && [llength [lindex $parentlist $commitrow($curview,$child)]] == 1} {
4543
+ && [llength $parents($curview,$child)] == 1} {
4544
set colormap($id) $colormap($child)
4545
return
4546
}
4568
&& [lsearch -exact $badcolors $colormap($child)] < 0} {
4569
lappend badcolors $colormap($child)
4570
}
3952
- foreach p [lindex $parentlist $commitrow($curview,$child)] {
4571
+ foreach p $parents($curview,$child) {
4572
if {[info exists colormap($p)]
4573
&& [lsearch -exact $badcolors $colormap($p)] < 0} {
4574
lappend badcolors $colormap($p)
4601
proc drawtags {id x xt y1} {
4602
global idtags idheads idotherrefs mainhead
4603
global linespc lthickness
3985
- global canv commitrow rowtextx curview fgcolor bgcolor
4604
+ global canv rowtextx curview fgcolor bgcolor
4605
4606
set marks {}
4607
set ntags 0
4651
$xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \
4652
-width 1 -outline black -fill yellow -tags tag.$id]
4653
$canv bind $t <1> [list showtag $tag 1]
4035
- set rowtextx($commitrow($curview,$id)) [expr {$xr + $linespc}]
4654
+ set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}]
4655
} else {
4656
# draw a head or other ref
4657
if {[incr nheads -1] >= 0} {
4705
-tags text -fill $fgcolor
4706
}
4707
4089
-# Insert a new commit as the child of the commit on row $row.
4090
-# The new commit will be displayed on row $row and the commits
4091
-# on that row and below will move down one row.
4092
-proc insertrow {row newcmit} {
4093
- global displayorder parentlist commitlisted children
4094
- global commitrow curview rowidlist rowisopt rowfinal numcommits
4095
- global numcommits
4096
- global selectedline commitidx ordertok
4097
-
4098
- if {$row >= $numcommits} {
4099
- puts "oops, inserting new row $row but only have $numcommits rows"
4100
- return
4101
- }
4102
- set p [lindex $displayorder $row]
4103
- set displayorder [linsert $displayorder $row $newcmit]
4104
- set parentlist [linsert $parentlist $row $p]
4105
- set kids $children($curview,$p)
4106
- lappend kids $newcmit
4107
- set children($curview,$p) $kids
4108
- set children($curview,$newcmit) {}
4109
- set commitlisted [linsert $commitlisted $row 1]
4110
- set l [llength $displayorder]
4111
- for {set r $row} {$r < $l} {incr r} {
4112
- set id [lindex $displayorder $r]
4113
- set commitrow($curview,$id) $r
4114
- }
4115
- incr commitidx($curview)
4116
- set ordertok($curview,$newcmit) $ordertok($curview,$p)
4117
-
4118
- if {$row < [llength $rowidlist]} {
4119
- set idlist [lindex $rowidlist $row]
4120
- if {$idlist ne {}} {
4121
- if {[llength $kids] == 1} {
4122
- set col [lsearch -exact $idlist $p]
4123
- lset idlist $col $newcmit
4124
- } else {
4125
- set col [llength $idlist]
4126
- lappend idlist $newcmit
4127
- }
4128
- }
4129
- set rowidlist [linsert $rowidlist $row $idlist]
4130
- set rowisopt [linsert $rowisopt $row 0]
4131
- set rowfinal [linsert $rowfinal $row [lindex $rowfinal $row]]
4132
- }
4133
-
4134
- incr numcommits
4135
-
4136
- if {[info exists selectedline] && $selectedline >= $row} {
4137
- incr selectedline
4138
- }
4139
- redisplay
4140
-}
4141
-
4142
-# Remove a commit that was inserted with insertrow on row $row.
4143
-proc removerow {row} {
4144
- global displayorder parentlist commitlisted children
4145
- global commitrow curview rowidlist rowisopt rowfinal numcommits
4146
- global numcommits
4147
- global linesegends selectedline commitidx
4148
-
4149
- if {$row >= $numcommits} {
4150
- puts "oops, removing row $row but only have $numcommits rows"
4151
- return
4152
- }
4153
- set rp1 [expr {$row + 1}]
4154
- set id [lindex $displayorder $row]
4155
- set p [lindex $parentlist $row]
4156
- set displayorder [lreplace $displayorder $row $row]
4157
- set parentlist [lreplace $parentlist $row $row]
4158
- set commitlisted [lreplace $commitlisted $row $row]
4159
- set kids $children($curview,$p)
4160
- set i [lsearch -exact $kids $id]
4161
- if {$i >= 0} {
4162
- set kids [lreplace $kids $i $i]
4163
- set children($curview,$p) $kids
4164
- }
4165
- set l [llength $displayorder]
4166
- for {set r $row} {$r < $l} {incr r} {
4167
- set id [lindex $displayorder $r]
4168
- set commitrow($curview,$id) $r
4169
- }
4170
- incr commitidx($curview) -1
4171
-
4172
- if {$row < [llength $rowidlist]} {
4173
- set rowidlist [lreplace $rowidlist $row $row]
4174
- set rowisopt [lreplace $rowisopt $row $row]
4175
- set rowfinal [lreplace $rowfinal $row $row]
4176
- }
4177
-
4178
- incr numcommits -1
4179
-
4180
- if {[info exists selectedline] && $selectedline > $row} {
4181
- incr selectedline -1
4182
- }
4183
- redisplay
4184
-}
4185
-
4708
# Don't change the text pane cursor if it is currently the hand cursor,
4709
# showing that we are over a sha1 ID link.
4710
proc settextcursor {c} {
4807
4808
proc findmore {} {
4809
global commitdata commitinfo numcommits findpattern findloc
4288
- global findstartline findcurline displayorder
4810
+ global findstartline findcurline findallowwrap
4811
global find_dirn gdttype fhighlights fprogcoord
4290
- global findallowwrap
4812
+ global curview varcorder vrownum varccommits
4813
4814
if {![info exists find_dirn]} {
4815
return 0
4847
}
4848
set found 0
4849
set domore 1
4850
+ set ai [bsearch $vrownum($curview) $l]
4851
+ set a [lindex $varcorder($curview) $ai]
4852
+ set arow [lindex $vrownum($curview) $ai]
4853
+ set ids [lindex $varccommits($curview,$a)]
4854
+ set arowend [expr {$arow + [llength $ids]}]
4855
if {$gdttype eq "containing:"} {
4856
for {} {$n > 0} {incr n -1; incr l $find_dirn} {
4330
- set id [lindex $displayorder $l]
4857
+ if {$l < $arow || $l >= $arowend} {
4858
+ incr ai $find_dirn
4859
+ set a [lindex $varcorder($curview) $ai]
4860
+ set arow [lindex $vrownum($curview) $ai]
4861
+ set ids [lindex $varccommits($curview,$a)]
4862
+ set arowend [expr {$arow + [llength $ids]}]
4863
+ }
4864
+ set id [lindex $ids [expr {$l - $arow}]]
4865
# shouldn't happen unless git log doesn't give all the commits...
4332
- if {![info exists commitdata($id)]} continue
4333
- if {![doesmatch $commitdata($id)]} continue
4866
+ if {![info exists commitdata($id)] ||
4867
+ ![doesmatch $commitdata($id)]} {
4868
+ continue
4869
+ }
4870
if {![info exists commitinfo($id)]} {
4871
getcommit $id
4872
}
4882
}
4883
} else {
4884
for {} {$n > 0} {incr n -1; incr l $find_dirn} {
4349
- set id [lindex $displayorder $l]
4885
+ if {$l < $arow || $l >= $arowend} {
4886
+ incr ai $find_dirn
4887
+ set a [lindex $varcorder($curview) $ai]
4888
+ set arow [lindex $vrownum($curview) $ai]
4889
+ set ids [lindex $varccommits($curview,$a)]
4890
+ set arowend [expr {$arow + [llength $ids]}]
4891
+ }
4892
+ set id [lindex $ids [expr {$l - $arow}]]
4893
if {![info exists fhighlights($l)]} {
4894
askfilehighlight $l $id
4895
if {$domore} {
5013
# append some text to the ctext widget, and make any SHA1 ID
5014
# that we know about be a clickable link.
5015
proc appendwithlinks {text tags} {
4473
- global ctext commitrow linknum curview pendinglinks
5016
+ global ctext linknum curview pendinglinks
5017
5018
set start [$ctext index "end - 1c"]
5019
$ctext insert end $text $tags
5031
}
5032
5033
proc setlink {id lk} {
4491
- global curview commitrow ctext pendinglinks commitinterest
5034
+ global curview ctext pendinglinks commitinterest
5035
4493
- if {[info exists commitrow($curview,$id)]} {
5036
+ if {[commitinview $id $curview]} {
5037
$ctext tag conf $lk -foreground blue -underline 1
4495
- $ctext tag bind $lk <1> [list selectline $commitrow($curview,$id) 1]
5038
+ $ctext tag bind $lk <1> [list selectline [rowofcommit $id] 1]
5039
$ctext tag bind $lk <Enter> {linkcursor %W 1}
5040
$ctext tag bind $lk <Leave> {linkcursor %W -1}
5041
} else {
5086
# add a list of tag or branch names at position pos
5087
# returns the number of names inserted
5088
proc appendrefs {pos ids var} {
4546
- global ctext commitrow linknum curview $var maxrefs
5089
+ global ctext linknum curview $var maxrefs
5090
5091
if {[catch {$ctext index $pos}]} {
5092
return 0
5189
5190
proc selectline {l isnew} {
5191
global canv ctext commitinfo selectedline
4649
- global displayorder
4650
- global canvy0 linespc parentlist children curview
5192
+ global canvy0 linespc parents children curview
5193
global currentid sha1entry
5194
global commentend idtags linknum
5195
global mergemax numcommits pending_select
5245
5246
set selectedline $l
5247
4706
- set id [lindex $displayorder $l]
5248
+ set id [commitonrow $l]
5249
set currentid $id
5250
$sha1entry delete 0 end
5251
$sha1entry insert 0 $id
5270
}
5271
5272
set headers {}
4731
- set olds [lindex $parentlist $l]
5273
+ set olds $parents($curview,$id)
5274
if {[llength $olds] > 1} {
5275
set np 0
5276
foreach p $olds {
5328
} elseif {[llength $olds] <= 1} {
5329
startdiff $id
5330
} else {
4789
- mergediff $id $l
5331
+ mergediff $id
5332
}
5333
}
5334
5573
return [expr {$nl >= 1000? 2: 1}]
5574
}
5575
5034
-proc mergediff {id l} {
5576
+proc mergediff {id} {
5577
global diffmergeid mdifffd
5578
global diffids
5037
- global parentlist
5579
+ global parents
5580
global limitdiffs viewfiles curview
5581
5582
set diffmergeid $id
5592
}
5593
fconfigure $mdf -blocking 0
5594
set mdifffd($id) $mdf
5053
- set np [llength [lindex $parentlist $l]]
5595
+ set np [llength $parents($curview,$id)]
5596
settabs $np
5597
filerun $mdf [list getmergediffline $mdf $id $np]
5598
}
6220
}
6221
6222
proc incrfont {inc} {
5681
- global mainfont textfont ctext canv phase cflist showrefstop
6223
+ global mainfont textfont ctext canv cflist showrefstop
6224
global stopped entries fontattr
6225
6226
unmarkmatches
6271
}
6272
6273
proc gotocommit {} {
5732
- global sha1string currentid commitrow tagids headids
5733
- global displayorder numcommits curview
6274
+ global sha1string tagids headids curview varcid
6275
6276
if {$sha1string == {}
6277
|| ([info exists currentid] && $sha1string == $currentid)} return
6282
} else {
6283
set id [string tolower $sha1string]
6284
if {[regexp {^[0-9a-f]{4,39}$} $id]} {
5744
- set matches {}
5745
- foreach i $displayorder {
5746
- if {[string match $id* $i]} {
5747
- lappend matches $i
5748
- }
5749
- }
6285
+ set matches [array names varcid "$curview,$id*"]
6286
if {$matches ne {}} {
6287
if {[llength $matches] > 1} {
6288
error_popup "Short SHA1 id $id is ambiguous"
6289
return
6290
}
5755
- set id [lindex $matches 0]
6291
+ set id [lindex [split [lindex $matches 0] ","] 1]
6292
}
6293
}
6294
}
5759
- if {[info exists commitrow($curview,$id)]} {
5760
- selectline $commitrow($curview,$id) 1
6295
+ if {[commitinview $id $curview]} {
6296
+ selectline [rowofcommit $id] 1
6297
return
6298
}
6299
if {[regexp {^[0-9a-fA-F]{4,}$} $sha1string]} {
6402
}
6403
6404
proc lineclick {x y id isnew} {
5869
- global ctext commitinfo children canv thickerline curview commitrow
6405
+ global ctext commitinfo children canv thickerline curview
6406
6407
if {![info exists commitinfo($id)] && ![getcommit $id]} return
6408
unmarkmatches
6470
}
6471
6472
proc selbyid {id} {
5937
- global commitrow curview
5938
- if {[info exists commitrow($curview,$id)]} {
5939
- selectline $commitrow($curview,$id) 1
6473
+ global curview
6474
+ if {[commitinview $id $curview]} {
6475
+ selectline [rowofcommit $id] 1
6476
}
6477
}
6478
6485
}
6486
6487
proc rowmenu {x y id} {
5952
- global rowctxmenu commitrow selectedline rowmenuid curview
6488
+ global rowctxmenu selectedline rowmenuid curview
6489
global nullid nullid2 fakerowmenu mainhead
6490
6491
stopfinding
6492
set rowmenuid $id
6493
if {![info exists selectedline]
5958
- || $commitrow($curview,$id) eq $selectedline} {
6494
+ || [rowofcommit $id] eq $selectedline} {
6495
set state disabled
6496
} else {
6497
set state normal
6509
}
6510
6511
proc diffvssel {dirn} {
5976
- global rowmenuid selectedline displayorder
6512
+ global rowmenuid selectedline
6513
6514
if {![info exists selectedline]} return
6515
if {$dirn} {
5980
- set oldid [lindex $displayorder $selectedline]
6516
+ set oldid [commitonrow $selectedline]
6517
set newid $rowmenuid
6518
} else {
6519
set oldid $rowmenuid
5984
- set newid [lindex $displayorder $selectedline]
6520
+ set newid [commitonrow $selectedline]
6521
}
6522
addtohistory [list doseldiff $oldid $newid]
6523
doseldiff $oldid $newid
6699
}
6700
6701
proc redrawtags {id} {
6166
- global canv linehtag commitrow idpos selectedline curview
6702
+ global canv linehtag idpos selectedline curview
6703
global canvxmax iddrawn
6704
6169
- if {![info exists commitrow($curview,$id)]} return
6705
+ if {![commitinview $id $curview]} return
6706
if {![info exists iddrawn($id)]} return
6171
- drawcommits $commitrow($curview,$id)
6707
+ drawcommits [rowofcommit $id]
6708
$canv delete tag.$id
6709
set xt [eval drawtags $id $idpos($id)]
6174
- $canv coords $linehtag($commitrow($curview,$id)) $xt [lindex $idpos($id) 2]
6175
- set text [$canv itemcget $linehtag($commitrow($curview,$id)) -text]
6710
+ $canv coords $linehtag([rowofcommit $id]) $xt [lindex $idpos($id) 2]
6711
+ set text [$canv itemcget $linehtag([rowofcommit $id]) -text]
6712
set xr [expr {$xt + [font measure mainfont $text]}]
6713
if {$xr > $canvxmax} {
6714
set canvxmax $xr
6715
setcanvscroll
6716
}
6717
if {[info exists selectedline]
6182
- && $selectedline == $commitrow($curview,$id)} {
6718
+ && $selectedline == [rowofcommit $id]} {
6719
selectline $selectedline 0
6720
}
6721
}
6842
}
6843
6844
proc cherrypick {} {
6309
- global rowmenuid curview commitrow
6845
+ global rowmenuid curview
6846
global mainhead
6847
6848
set oldhead [exec git rev-parse HEAD]
6868
return
6869
}
6870
addnewchild $newhead $oldhead
6335
- if {[info exists commitrow($curview,$oldhead)]} {
6336
- insertrow $commitrow($curview,$oldhead) $newhead
6871
+ if {[commitinview $oldhead $curview]} {
6872
+ insertrow $newhead $oldhead $curview
6873
if {$mainhead ne {}} {
6874
movehead $newhead $mainhead
6875
movedhead $newhead $mainhead
7107
7108
proc refill_reflist {} {
7109
global reflist reflistfilter showrefstop headids tagids otherrefids
6574
- global commitrow curview commitinterest
7110
+ global curview commitinterest
7111
7112
if {![info exists showrefstop] || ![winfo exists $showrefstop]} return
7113
set refs {}
7114
foreach n [array names headids] {
7115
if {[string match $reflistfilter $n]} {
6580
- if {[info exists commitrow($curview,$headids($n))]} {
7116
+ if {[commitinview $headids($n) $curview]} {
7117
lappend refs [list $n H]
7118
} else {
7119
set commitinterest($headids($n)) {run refill_reflist}
7122
}
7123
foreach n [array names tagids] {
7124
if {[string match $reflistfilter $n]} {
6589
- if {[info exists commitrow($curview,$tagids($n))]} {
7125
+ if {[commitinview $tagids($n) $curview]} {
7126
lappend refs [list $n T]
7127
} else {
7128
set commitinterest($tagids($n)) {run refill_reflist}
7131
}
7132
foreach n [array names otherrefids] {
7133
if {[string match $reflistfilter $n]} {
6598
- if {[info exists commitrow($curview,$otherrefids($n))]} {
7134
+ if {[commitinview $otherrefids($n) $curview]} {
7135
lappend refs [list $n o]
7136
} else {
7137
set commitinterest($otherrefids($n)) {run refill_reflist}
9155
set viewperm(0) 0
9156
set viewargs(0) {}
9157
9158
+set loginstance 0
9159
+set getdbg 0
9160
set cmdlineok 0
9161
set stopped 0
9162
set stuffsaved 0
9163
set patchnum 0
8626
-set localirow -1
8627
-set localfrow -1
9164
set lserial 0
9165
setcoords
9166
makewindow