gitk: Use git-diff-tree --cc for showing the diffs for merges
This replaces a lot of code that used the result from several 2-way diffs to generate a combined diff for a merge. Now we just use git-diff-tree --cc and colorize the output a bit, which is a lot simpler, and has the enormous advantage that if the diff doesn't show quite what someone thinks it should show, I can deflect the blame to someone else. :) Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Feb 7, 2006 at 09:13 UTC
b77b02785d2f589ca336fc449ee1c27837263dac
1 file changed
+99
-501
gitk
+99
-501
@@ -542,8 +542,19 @@ proc makewindow {rargs} {
542
$ctext tag conf m2 -fore green
543
$ctext tag conf m3 -fore purple
544
$ctext tag conf m4 -fore brown
545
+ $ctext tag conf m5 -fore "#009090"
546
+ $ctext tag conf m6 -fore magenta
547
+ $ctext tag conf m7 -fore "#808000"
548
+ $ctext tag conf m8 -fore "#009000"
549
+ $ctext tag conf m9 -fore "#ff0080"
550
+ $ctext tag conf m10 -fore cyan
551
+ $ctext tag conf m11 -fore "#b07070"
552
+ $ctext tag conf m12 -fore "#70b0f0"
553
+ $ctext tag conf m13 -fore "#70f0b0"
554
+ $ctext tag conf m14 -fore "#f0b070"
555
+ $ctext tag conf m15 -fore "#ff70b0"
556
$ctext tag conf mmax -fore darkgrey
546
- set mergemax 5
557
+ set mergemax 16
558
$ctext tag conf mresult -font [concat $textfont bold]
559
$ctext tag conf msep -font [concat $textfont bold]
560
$ctext tag conf found -back yellow
@@ -2182,6 +2193,7 @@ proc selectline {l isnew} {
2193
global canvy0 linespc parents nparents children
2194
global cflist currentid sha1entry
2195
global commentend idtags idline linknum
2196
+ global mergemax
2197
2198
$canv delete hover
2199
normalline
@@ -2265,11 +2277,26 @@ proc selectline {l isnew} {
2277
}
2278
2279
set comment {}
2268
- if {[info exists parents($id)]} {
2280
+ if {$nparents($id) > 1} {
2281
+ set np 0
2282
foreach p $parents($id) {
2270
- append comment "Parent: [commit_descriptor $p]\n"
2283
+ if {$np >= $mergemax} {
2284
+ set tag mmax
2285
+ } else {
2286
+ set tag m$np
2287
+ }
2288
+ $ctext insert end "Parent: " $tag
2289
+ appendwithlinks [commit_descriptor $p]
2290
+ incr np
2291
+ }
2292
+ } else {
2293
+ if {[info exists parents($id)]} {
2294
+ foreach p $parents($id) {
2295
+ append comment "Parent: [commit_descriptor $p]\n"
2296
+ }
2297
}
2298
}
2299
+
2300
if {[info exists children($id)]} {
2301
foreach c $children($id) {
2302
append comment "Child: [commit_descriptor $c]\n"
@@ -2361,529 +2388,100 @@ proc goforw {} {
2388
}
2389
2390
proc mergediff {id} {
2364
- global parents diffmergeid diffmergegca mergefilelist diffpindex
2391
+ global parents diffmergeid diffopts mdifffd
2392
+ global difffilestart
2393
2394
set diffmergeid $id
2367
- set diffpindex -1
2368
- set diffmergegca [findgca $parents($id)]
2369
- if {[info exists mergefilelist($id)]} {
2370
- if {$mergefilelist($id) ne {}} {
2371
- showmergediff
2372
- }
2373
- } else {
2374
- contmergediff {}
2375
- }
2376
-}
2377
-
2378
-proc findgca {ids} {
2379
- set gca {}
2380
- foreach id $ids {
2381
- if {$gca eq {}} {
2382
- set gca $id
2383
- } else {
2384
- if {[catch {
2385
- set gca [exec git-merge-base $gca $id]
2386
- } err]} {
2387
- return {}
2388
- }
2389
- }
2390
- }
2391
- return $gca
2392
-}
2393
-
2394
-proc contmergediff {ids} {
2395
- global diffmergeid diffpindex parents nparents diffmergegca
2396
- global treediffs mergefilelist diffids treepending
2397
-
2398
- # diff the child against each of the parents, and diff
2399
- # each of the parents against the GCA.
2400
- while 1 {
2401
- if {[lindex $ids 1] == $diffmergeid && $diffmergegca ne {}} {
2402
- set ids [list $diffmergegca [lindex $ids 0]]
2403
- } else {
2404
- if {[incr diffpindex] >= $nparents($diffmergeid)} break
2405
- set p [lindex $parents($diffmergeid) $diffpindex]
2406
- set ids [list $p $diffmergeid]
2407
- }
2408
- if {![info exists treediffs($ids)]} {
2409
- set diffids $ids
2410
- if {![info exists treepending]} {
2411
- gettreediffs $ids
2412
- }
2413
- return
2414
- }
2415
- }
2416
-
2417
- # If a file in some parent is different from the child and also
2418
- # different from the GCA, then it's interesting.
2419
- # If we don't have a GCA, then a file is interesting if it is
2420
- # different from the child in all the parents.
2421
- if {$diffmergegca ne {}} {
2422
- set files {}
2423
- foreach p $parents($diffmergeid) {
2424
- set gcadiffs $treediffs([list $diffmergegca $p])
2425
- foreach f $treediffs([list $p $diffmergeid]) {
2426
- if {[lsearch -exact $files $f] < 0
2427
- && [lsearch -exact $gcadiffs $f] >= 0} {
2428
- lappend files $f
2429
- }
2430
- }
2431
- }
2432
- set files [lsort $files]
2433
- } else {
2434
- set p [lindex $parents($diffmergeid) 0]
2435
- set files $treediffs([list $diffmergeid $p])
2436
- for {set i 1} {$i < $nparents($diffmergeid) && $files ne {}} {incr i} {
2437
- set p [lindex $parents($diffmergeid) $i]
2438
- set df $treediffs([list $p $diffmergeid])
2439
- set nf {}
2440
- foreach f $files {
2441
- if {[lsearch -exact $df $f] >= 0} {
2442
- lappend nf $f
2443
- }
2444
- }
2445
- set files $nf
2446
- }
2447
- }
2448
-
2449
- set mergefilelist($diffmergeid) $files
2450
- if {$files ne {}} {
2451
- showmergediff
2452
- }
2453
-}
2454
-
2455
-proc showmergediff {} {
2456
- global cflist diffmergeid mergefilelist parents
2457
- global diffopts diffinhunk currentfile currenthunk filelines
2458
- global diffblocked groupfilelast mergefds groupfilenum grouphunks
2459
-
2460
- set files $mergefilelist($diffmergeid)
2461
- foreach f $files {
2462
- $cflist insert end $f
2463
- }
2395
+ catch {unset difffilestart}
2396
+ # this doesn't seem to actually affect anything...
2397
set env(GIT_DIFF_OPTS) $diffopts
2465
- set flist {}
2466
- catch {unset currentfile}
2467
- catch {unset currenthunk}
2468
- catch {unset filelines}
2469
- catch {unset groupfilenum}
2470
- catch {unset grouphunks}
2471
- set groupfilelast -1
2472
- foreach p $parents($diffmergeid) {
2473
- set cmd [list | git-diff-tree -p $p $diffmergeid]
2474
- set cmd [concat $cmd $mergefilelist($diffmergeid)]
2475
- if {[catch {set f [open $cmd r]} err]} {
2476
- error_popup "Error getting diffs: $err"
2477
- foreach f $flist {
2478
- catch {close $f}
2479
- }
2480
- return
2481
- }
2482
- lappend flist $f
2483
- set ids [list $diffmergeid $p]
2484
- set mergefds($ids) $f
2485
- set diffinhunk($ids) 0
2486
- set diffblocked($ids) 0
2487
- fconfigure $f -blocking 0
2488
- fileevent $f readable [list getmergediffline $f $ids $diffmergeid]
2398
+ set cmd [concat | git-diff-tree --no-commit-id --cc $id]
2399
+ if {[catch {set mdf [open $cmd r]} err]} {
2400
+ error_popup "Error getting merge diffs: $err"
2401
+ return
2402
}
2403
+ fconfigure $mdf -blocking 0
2404
+ set mdifffd($id) $mdf
2405
+ fileevent $mdf readable [list getmergediffline $mdf $id]
2406
+ set nextupdate [expr {[clock clicks -milliseconds] + 100}]
2407
}
2408
2492
-proc getmergediffline {f ids id} {
2493
- global diffmergeid diffinhunk diffoldlines diffnewlines
2494
- global currentfile currenthunk
2495
- global diffoldstart diffnewstart diffoldlno diffnewlno
2496
- global diffblocked mergefilelist
2497
- global noldlines nnewlines difflcounts filelines
2409
+proc getmergediffline {mdf id} {
2410
+ global diffmergeid ctext cflist nextupdate nparents mergemax
2411
+ global difffilestart
2412
2499
- set n [gets $f line]
2413
+ set n [gets $mdf line]
2414
if {$n < 0} {
2501
- if {![eof $f]} return
2502
- }
2503
-
2504
- if {!([info exists diffmergeid] && $diffmergeid == $id)} {
2505
- if {$n < 0} {
2506
- close $f
2415
+ if {[eof $mdf]} {
2416
+ close $mdf
2417
}
2418
return
2419
}
2510
-
2511
- if {$diffinhunk($ids) != 0} {
2512
- set fi $currentfile($ids)
2513
- if {$n > 0 && [regexp {^[-+ \\]} $line match]} {
2514
- # continuing an existing hunk
2515
- set line [string range $line 1 end]
2516
- set p [lindex $ids 1]
2517
- if {$match eq "-" || $match eq " "} {
2518
- set filelines($p,$fi,$diffoldlno($ids)) $line
2519
- incr diffoldlno($ids)
2520
- }
2521
- if {$match eq "+" || $match eq " "} {
2522
- set filelines($id,$fi,$diffnewlno($ids)) $line
2523
- incr diffnewlno($ids)
2524
- }
2525
- if {$match eq " "} {
2526
- if {$diffinhunk($ids) == 2} {
2527
- lappend difflcounts($ids) \
2528
- [list $noldlines($ids) $nnewlines($ids)]
2529
- set noldlines($ids) 0
2530
- set diffinhunk($ids) 1
2531
- }
2532
- incr noldlines($ids)
2533
- } elseif {$match eq "-" || $match eq "+"} {
2534
- if {$diffinhunk($ids) == 1} {
2535
- lappend difflcounts($ids) [list $noldlines($ids)]
2536
- set noldlines($ids) 0
2537
- set nnewlines($ids) 0
2538
- set diffinhunk($ids) 2
2539
- }
2540
- if {$match eq "-"} {
2541
- incr noldlines($ids)
2542
- } else {
2543
- incr nnewlines($ids)
2544
- }
2545
- }
2546
- # and if it's \ No newline at end of line, then what?
2547
- return
2548
- }
2549
- # end of a hunk
2550
- if {$diffinhunk($ids) == 1 && $noldlines($ids) != 0} {
2551
- lappend difflcounts($ids) [list $noldlines($ids)]
2552
- } elseif {$diffinhunk($ids) == 2
2553
- && ($noldlines($ids) != 0 || $nnewlines($ids) != 0)} {
2554
- lappend difflcounts($ids) [list $noldlines($ids) $nnewlines($ids)]
2555
- }
2556
- set currenthunk($ids) [list $currentfile($ids) \
2557
- $diffoldstart($ids) $diffnewstart($ids) \
2558
- $diffoldlno($ids) $diffnewlno($ids) \
2559
- $difflcounts($ids)]
2560
- set diffinhunk($ids) 0
2561
- # -1 = need to block, 0 = unblocked, 1 = is blocked
2562
- set diffblocked($ids) -1
2563
- processhunks
2564
- if {$diffblocked($ids) == -1} {
2565
- fileevent $f readable {}
2566
- set diffblocked($ids) 1
2567
- }
2568
- }
2569
-
2570
- if {$n < 0} {
2571
- # eof
2572
- if {!$diffblocked($ids)} {
2573
- close $f
2574
- set currentfile($ids) [llength $mergefilelist($diffmergeid)]
2575
- set currenthunk($ids) [list $currentfile($ids) 0 0 0 0 {}]
2576
- processhunks
2577
- }
2578
- } elseif {[regexp {^diff --git a/(.*) b/} $line match fname]} {
2579
- # start of a new file
2580
- set currentfile($ids) \
2581
- [lsearch -exact $mergefilelist($diffmergeid) $fname]
2582
- } elseif {[regexp {^@@ -([0-9]+),([0-9]+) \+([0-9]+),([0-9]+) @@(.*)} \
2583
- $line match f1l f1c f2l f2c rest]} {
2584
- if {[info exists currentfile($ids)] && $currentfile($ids) >= 0} {
2585
- # start of a new hunk
2586
- if {$f1l == 0 && $f1c == 0} {
2587
- set f1l 1
2588
- }
2589
- if {$f2l == 0 && $f2c == 0} {
2590
- set f2l 1
2591
- }
2592
- set diffinhunk($ids) 1
2593
- set diffoldstart($ids) $f1l
2594
- set diffnewstart($ids) $f2l
2595
- set diffoldlno($ids) $f1l
2596
- set diffnewlno($ids) $f2l
2597
- set difflcounts($ids) {}
2598
- set noldlines($ids) 0
2599
- set nnewlines($ids) 0
2600
- }
2601
- }
2602
-}
2603
-
2604
-proc processhunks {} {
2605
- global diffmergeid parents nparents currenthunk
2606
- global mergefilelist diffblocked mergefds
2607
- global grouphunks grouplinestart grouplineend groupfilenum
2608
-
2609
- set nfiles [llength $mergefilelist($diffmergeid)]
2610
- while 1 {
2611
- set fi $nfiles
2612
- set lno 0
2613
- # look for the earliest hunk
2614
- foreach p $parents($diffmergeid) {
2615
- set ids [list $diffmergeid $p]
2616
- if {![info exists currenthunk($ids)]} return
2617
- set i [lindex $currenthunk($ids) 0]
2618
- set l [lindex $currenthunk($ids) 2]
2619
- if {$i < $fi || ($i == $fi && $l < $lno)} {
2620
- set fi $i
2621
- set lno $l
2622
- set pi $p
2623
- }
2624
- }
2625
-
2626
- if {$fi < $nfiles} {
2627
- set ids [list $diffmergeid $pi]
2628
- set hunk $currenthunk($ids)
2629
- unset currenthunk($ids)
2630
- if {$diffblocked($ids) > 0} {
2631
- fileevent $mergefds($ids) readable \
2632
- [list getmergediffline $mergefds($ids) $ids $diffmergeid]
2633
- }
2634
- set diffblocked($ids) 0
2635
-
2636
- if {[info exists groupfilenum] && $groupfilenum == $fi
2637
- && $lno <= $grouplineend} {
2638
- # add this hunk to the pending group
2639
- lappend grouphunks($pi) $hunk
2640
- set endln [lindex $hunk 4]
2641
- if {$endln > $grouplineend} {
2642
- set grouplineend $endln
2643
- }
2644
- continue
2645
- }
2646
- }
2647
-
2648
- # succeeding stuff doesn't belong in this group, so
2649
- # process the group now
2650
- if {[info exists groupfilenum]} {
2651
- processgroup
2652
- unset groupfilenum
2653
- unset grouphunks
2654
- }
2655
-
2656
- if {$fi >= $nfiles} break
2657
-
2658
- # start a new group
2659
- set groupfilenum $fi
2660
- set grouphunks($pi) [list $hunk]
2661
- set grouplinestart $lno
2662
- set grouplineend [lindex $hunk 4]
2420
+ if {![info exists diffmergeid] || $id != $diffmergeid} {
2421
+ return
2422
}
2664
-}
2665
-
2666
-proc processgroup {} {
2667
- global groupfilelast groupfilenum difffilestart
2668
- global mergefilelist diffmergeid ctext filelines
2669
- global parents diffmergeid diffoffset
2670
- global grouphunks grouplinestart grouplineend nparents
2671
- global mergemax
2672
-
2423
$ctext conf -state normal
2674
- set id $diffmergeid
2675
- set f $groupfilenum
2676
- if {$groupfilelast != $f} {
2424
+ if {[regexp {^diff --cc (.*)} $line match fname]} {
2425
+ # start of a new file
2426
$ctext insert end "\n"
2427
set here [$ctext index "end - 1c"]
2679
- set difffilestart($f) $here
2680
- set mark fmark.[expr {$f + 1}]
2681
- $ctext mark set $mark $here
2682
- $ctext mark gravity $mark left
2683
- set header [lindex $mergefilelist($id) $f]
2684
- set l [expr {(78 - [string length $header]) / 2}]
2428
+ set i [$cflist index end]
2429
+ $ctext mark set fmark.$i $here
2430
+ $ctext mark gravity fmark.$i left
2431
+ set difffilestart([expr {$i-1}]) $here
2432
+ $cflist insert end $fname
2433
+ set l [expr {(78 - [string length $fname]) / 2}]
2434
set pad [string range "----------------------------------------" 1 $l]
2686
- $ctext insert end "$pad $header $pad\n" filesep
2687
- set groupfilelast $f
2688
- foreach p $parents($id) {
2689
- set diffoffset($p) 0
2690
- }
2691
- }
2692
-
2693
- $ctext insert end "@@" msep
2694
- set nlines [expr {$grouplineend - $grouplinestart}]
2695
- set events {}
2696
- set pnum 0
2697
- foreach p $parents($id) {
2698
- set startline [expr {$grouplinestart + $diffoffset($p)}]
2699
- set ol $startline
2700
- set nl $grouplinestart
2701
- if {[info exists grouphunks($p)]} {
2702
- foreach h $grouphunks($p) {
2703
- set l [lindex $h 2]
2704
- if {$nl < $l} {
2705
- for {} {$nl < $l} {incr nl} {
2706
- set filelines($p,$f,$ol) $filelines($id,$f,$nl)
2707
- incr ol
2708
- }
2709
- }
2710
- foreach chunk [lindex $h 5] {
2711
- if {[llength $chunk] == 2} {
2712
- set olc [lindex $chunk 0]
2713
- set nlc [lindex $chunk 1]
2714
- set nnl [expr {$nl + $nlc}]
2715
- lappend events [list $nl $nnl $pnum $olc $nlc]
2716
- incr ol $olc
2717
- set nl $nnl
2718
- } else {
2719
- incr ol [lindex $chunk 0]
2720
- incr nl [lindex $chunk 0]
2721
- }
2722
- }
2723
- }
2724
- }
2725
- if {$nl < $grouplineend} {
2726
- for {} {$nl < $grouplineend} {incr nl} {
2727
- set filelines($p,$f,$ol) $filelines($id,$f,$nl)
2728
- incr ol
2729
- }
2730
- }
2731
- set nlines [expr {$ol - $startline}]
2732
- $ctext insert end " -$startline,$nlines" msep
2733
- incr pnum
2734
- }
2735
-
2736
- set nlines [expr {$grouplineend - $grouplinestart}]
2737
- $ctext insert end " +$grouplinestart,$nlines @@\n" msep
2738
-
2739
- set events [lsort -integer -index 0 $events]
2740
- set nevents [llength $events]
2741
- set nmerge $nparents($diffmergeid)
2742
- set l $grouplinestart
2743
- for {set i 0} {$i < $nevents} {set i $j} {
2744
- set nl [lindex $events $i 0]
2745
- while {$l < $nl} {
2746
- $ctext insert end " $filelines($id,$f,$l)\n"
2747
- incr l
2748
- }
2749
- set e [lindex $events $i]
2750
- set enl [lindex $e 1]
2751
- set j $i
2752
- set active {}
2753
- while 1 {
2754
- set pnum [lindex $e 2]
2755
- set olc [lindex $e 3]
2756
- set nlc [lindex $e 4]
2757
- if {![info exists delta($pnum)]} {
2758
- set delta($pnum) [expr {$olc - $nlc}]
2759
- lappend active $pnum
2435
+ $ctext insert end "$pad $fname $pad\n" filesep
2436
+ } elseif {[regexp {^@@} $line]} {
2437
+ $ctext insert end "$line\n" hunksep
2438
+ } elseif {[regexp {^[0-9a-f]{40}$} $line] || [regexp {^index} $line]} {
2439
+ # do nothing
2440
+ } else {
2441
+ # parse the prefix - one ' ', '-' or '+' for each parent
2442
+ set np $nparents($id)
2443
+ set spaces {}
2444
+ set minuses {}
2445
+ set pluses {}
2446
+ set isbad 0
2447
+ for {set j 0} {$j < $np} {incr j} {
2448
+ set c [string range $line $j $j]
2449
+ if {$c == " "} {
2450
+ lappend spaces $j
2451
+ } elseif {$c == "-"} {
2452
+ lappend minuses $j
2453
+ } elseif {$c == "+"} {
2454
+ lappend pluses $j
2455
} else {
2761
- incr delta($pnum) [expr {$olc - $nlc}]
2762
- }
2763
- if {[incr j] >= $nevents} break
2764
- set e [lindex $events $j]
2765
- if {[lindex $e 0] >= $enl} break
2766
- if {[lindex $e 1] > $enl} {
2767
- set enl [lindex $e 1]
2768
- }
2769
- }
2770
- set nlc [expr {$enl - $l}]
2771
- set ncol mresult
2772
- set bestpn -1
2773
- if {[llength $active] == $nmerge - 1} {
2774
- # no diff for one of the parents, i.e. it's identical
2775
- for {set pnum 0} {$pnum < $nmerge} {incr pnum} {
2776
- if {![info exists delta($pnum)]} {
2777
- if {$pnum < $mergemax} {
2778
- lappend ncol m$pnum
2779
- } else {
2780
- lappend ncol mmax
2781
- }
2782
- break
2783
- }
2784
- }
2785
- } elseif {[llength $active] == $nmerge} {
2786
- # all parents are different, see if one is very similar
2787
- set bestsim 30
2788
- for {set pnum 0} {$pnum < $nmerge} {incr pnum} {
2789
- set sim [similarity $pnum $l $nlc $f \
2790
- [lrange $events $i [expr {$j-1}]]]
2791
- if {$sim > $bestsim} {
2792
- set bestsim $sim
2793
- set bestpn $pnum
2794
- }
2795
- }
2796
- if {$bestpn >= 0} {
2797
- lappend ncol m$bestpn
2456
+ set isbad 1
2457
+ break
2458
}
2459
}
2800
- set pnum -1
2801
- foreach p $parents($id) {
2802
- incr pnum
2803
- if {![info exists delta($pnum)] || $pnum == $bestpn} continue
2804
- set olc [expr {$nlc + $delta($pnum)}]
2805
- set ol [expr {$l + $diffoffset($p)}]
2806
- incr diffoffset($p) $delta($pnum)
2807
- unset delta($pnum)
2808
- for {} {$olc > 0} {incr olc -1} {
2809
- $ctext insert end "-$filelines($p,$f,$ol)\n" m$pnum
2810
- incr ol
2811
- }
2460
+ set tags {}
2461
+ set num {}
2462
+ if {!$isbad && $minuses ne {} && $pluses eq {}} {
2463
+ # line doesn't appear in result, parents in $minuses have the line
2464
+ set num [lindex $minuses 0]
2465
+ } elseif {!$isbad && $pluses ne {} && $minuses eq {}} {
2466
+ # line appears in result, parents in $pluses don't have the line
2467
+ lappend tags mresult
2468
+ set num [lindex $spaces 0]
2469
}
2813
- set endl [expr {$l + $nlc}]
2814
- if {$bestpn >= 0} {
2815
- # show this pretty much as a normal diff
2816
- set p [lindex $parents($id) $bestpn]
2817
- set ol [expr {$l + $diffoffset($p)}]
2818
- incr diffoffset($p) $delta($bestpn)
2819
- unset delta($bestpn)
2820
- for {set k $i} {$k < $j} {incr k} {
2821
- set e [lindex $events $k]
2822
- if {[lindex $e 2] != $bestpn} continue
2823
- set nl [lindex $e 0]
2824
- set ol [expr {$ol + $nl - $l}]
2825
- for {} {$l < $nl} {incr l} {
2826
- $ctext insert end "+$filelines($id,$f,$l)\n" $ncol
2827
- }
2828
- set c [lindex $e 3]
2829
- for {} {$c > 0} {incr c -1} {
2830
- $ctext insert end "-$filelines($p,$f,$ol)\n" m$bestpn
2831
- incr ol
2832
- }
2833
- set nl [lindex $e 1]
2834
- for {} {$l < $nl} {incr l} {
2835
- $ctext insert end "+$filelines($id,$f,$l)\n" mresult
2836
- }
2470
+ if {$num ne {}} {
2471
+ if {$num >= $mergemax} {
2472
+ set num "max"
2473
}
2474
+ lappend tags m$num
2475
}
2839
- for {} {$l < $endl} {incr l} {
2840
- $ctext insert end "+$filelines($id,$f,$l)\n" $ncol
2841
- }
2842
- }
2843
- while {$l < $grouplineend} {
2844
- $ctext insert end " $filelines($id,$f,$l)\n"
2845
- incr l
2476
+ $ctext insert end "$line\n" $tags
2477
}
2478
$ctext conf -state disabled
2848
-}
2849
-
2850
-proc similarity {pnum l nlc f events} {
2851
- global diffmergeid parents diffoffset filelines
2852
-
2853
- set id $diffmergeid
2854
- set p [lindex $parents($id) $pnum]
2855
- set ol [expr {$l + $diffoffset($p)}]
2856
- set endl [expr {$l + $nlc}]
2857
- set same 0
2858
- set diff 0
2859
- foreach e $events {
2860
- if {[lindex $e 2] != $pnum} continue
2861
- set nl [lindex $e 0]
2862
- set ol [expr {$ol + $nl - $l}]
2863
- for {} {$l < $nl} {incr l} {
2864
- incr same [string length $filelines($id,$f,$l)]
2865
- incr same
2866
- }
2867
- set oc [lindex $e 3]
2868
- for {} {$oc > 0} {incr oc -1} {
2869
- incr diff [string length $filelines($p,$f,$ol)]
2870
- incr diff
2871
- incr ol
2872
- }
2873
- set nl [lindex $e 1]
2874
- for {} {$l < $nl} {incr l} {
2875
- incr diff [string length $filelines($id,$f,$l)]
2876
- incr diff
2877
- }
2878
- }
2879
- for {} {$l < $endl} {incr l} {
2880
- incr same [string length $filelines($id,$f,$l)]
2881
- incr same
2882
- }
2883
- if {$same == 0} {
2884
- return 0
2479
+ if {[clock clicks -milliseconds] >= $nextupdate} {
2480
+ incr nextupdate 100
2481
+ fileevent $mdf readable {}
2482
+ update
2483
+ fileevent $mdf readable [list getmergediffline $mdf $id]
2484
}
2886
- return [expr {200 * $same / (2 * $same + $diff)}]
2485
}
2486
2487
proc startdiff {ids} {