Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Removed compareLines and use DiffUtil::diffStrings instead. Removed option "second stage" and let it be on always. Centralised map handling in a few functions. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3ea2fde2eca29968eaa74b51640a2786 |
User & Date: | peter 2004-05-24 14:46:35.000 |
Context
2004-05-26
| ||
10:26 | Release 2.0.3 check-in: 6cc82856ad user: peter tags: trunk | |
2004-05-24
| ||
14:46 | Removed compareLines and use DiffUtil::diffStrings instead. Removed option "second stage" and let it be on always. Centralised map handling in a few functions. check-in: 3ea2fde2ec user: peter tags: trunk | |
11:36 | Added map at dirdiff scrollbar. Redesigned font selector a bit using newer widgets. Added menu entry to step down in either side in dirdiff. Added Help menu in dirdiff window. Provide some info to help DiffUtil to locate diff executable. check-in: b217995849 user: peter tags: trunk | |
Changes
Changes to src/eskil.tcl.
︙ | ︙ | |||
153 154 155 156 157 158 159 | foreach f $::tmpfiles { catch {file delete $f} } set ::tmpfiles {} } } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < | < | | | | < < | | | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | foreach f $::tmpfiles { catch {file delete $f} } set ::tmpfiles {} } } # Compare two lines and rate how much they resemble each other. # This has never worked well. Some day I'll sit down, think this through, # and come up with a better algorithm. proc compareLines2 {line1 line2} { set res [DiffUtil::diffStrings $line1 $line2] # Collect identical pieces and different pieces set sames {} set diffs1 {} set diffs2 {} foreach {same1 same2 diff1 diff2} $res { lappend sames $same1 if {$diff1 != ""} { lappend diffs1 $diff1 } if {$diff2 != ""} { lappend diffs2 $diff2 } } set sumsame 0 set sumdiff1 0 set sumdiff2 0 foreach same $sames { set apa [string length [string trim $same]] |
︙ | ︙ | |||
729 730 731 732 733 734 735 | set ::diff(filterflag) 1 return } set ::diff(filterflag) 0 } if {$Pref(parse) != 0} { | | | | < < < < < | | | 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | set ::diff(filterflag) 1 return } set ::diff(filterflag) 0 } if {$Pref(parse) != 0} { set opts $Pref(ignore) if {$Pref(lineparsewords)} {lappend opts -words} set res [eval DiffUtil::diffStrings $opts \$line1 \$line2] set dotag 0 set n [expr {[llength $res] / 2}] $::widgets($top,wLine1) insert end [myFormL $doingLine1] "hl$::HighLightCount change" $::widgets($top,wLine2) insert end [myFormL $doingLine2] "hl$::HighLightCount change" set new1 "new1" set new2 "new2" set change "change" foreach {i1 i2} $res { incr n -1 if {$dotag} { if {$n == 1 && $Pref(marklast)} { lappend new1 last lappend new2 last lappend change last } |
︙ | ︙ | |||
866 867 868 869 870 871 872 | } } set t 0 while {[gets $ch2 apa] != -1} { if {$line2 > 0 && $doingLine2 > $line2} break insertLine $top 2 $doingLine2 $apa incr doingLine2 | | | 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | } } set t 0 while {[gets $ch2 apa] != -1} { if {$line2 > 0 && $doingLine2 > $line2} break insertLine $top 2 $doingLine2 $apa incr doingLine2 addMapLines $top 1 incr t if {$limit >= 0 && $t >= $limit} break } set t 0 while {[gets $ch1 apa] != -1} { if {$line1 > 0 && $doingLine1 > $line1} break insertLine $top 1 $doingLine1 $apa |
︙ | ︙ | |||
901 902 903 904 905 906 907 | while {$doingLine1 < $line1} { gets $ch1 apa gets $ch2 bepa if {$limit < 0 || ($t < $limit) || \ ($line1 - $doingLine1) <= $limit} { insertLine $top 1 $doingLine1 $apa insertLine $top 2 $doingLine2 $bepa | | | | 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | while {$doingLine1 < $line1} { gets $ch1 apa gets $ch2 bepa if {$limit < 0 || ($t < $limit) || \ ($line1 - $doingLine1) <= $limit} { insertLine $top 1 $doingLine1 $apa insertLine $top 2 $doingLine2 $bepa addMapLines $top 1 } elseif {$t == $limit} { emptyLine $top 1 0 emptyLine $top 2 0 addMapLines $top 1 } incr doingLine1 incr doingLine2 incr t if {$::diff($top,limitlines) && \ ($::diff($top,mapMax) > $::diff($top,limitlines))} { return |
︙ | ︙ | |||
937 938 939 940 941 942 943 | # blocks of equal size. for {set t 0} {$t < $n1} {incr t} { gets $ch1 textline1 gets $ch2 textline2 insertMatchingLines $top $textline1 $textline2 } if {$::diff(filter) != "" && $::diff(filterflag)} { | | < | < < | < < | < < | < | 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 | # blocks of equal size. for {set t 0} {$t < $n1} {incr t} { gets $ch1 textline1 gets $ch2 textline2 insertMatchingLines $top $textline1 $textline2 } if {$::diff(filter) != "" && $::diff(filterflag)} { addMapLines $top $n1 } else { addChange $top $n1 change $line1 $n1 $line2 $n2 } } else { if {$n1 != 0 && $n2 != 0 && $Pref(parse) >= 2 && \ ($n1 * $n2 < 1000 || $Pref(parse) == 3)} { # Full block parsing set block1 {} for {set t 0} {$t < $n1} {incr t} { gets $ch1 apa lappend block1 $apa } set block2 {} for {set t 0} {$t < $n2} {incr t} { gets $ch2 apa lappend block2 $apa } set apa [insertMatchingBlocks $top $block1 $block2] addChange $top $apa change $line1 $n1 $line2 $n2 } else { # No extra parsing at all. for {set t 0} {$t < $n1} {incr t} { gets $ch1 apa insertLine $top 1 $doingLine1 $apa $tag1 incr doingLine1 } for {set t 0} {$t < $n2} {incr t} { gets $ch2 apa insertLine $top 2 $doingLine2 $apa $tag2 incr doingLine2 } if {$n1 <= $n2} { for {set t $n1} {$t < $n2} {incr t} { emptyLine $top 1 } addChange $top $n2 $tag2 $line1 $n1 $line2 $n2 } elseif {$n2 < $n1} { for {set t $n2} {$t < $n1} {incr t} { emptyLine $top 2 } addChange $top $n1 $tag1 $line1 $n1 $line2 $n2 } } } } proc enableRedo {top} { $top.mf.m entryconfigure "Redo Diff" -state normal |
︙ | ︙ | |||
1165 1166 1167 1168 1169 1170 1171 | } continue } # No change block anymore. If one just ended, display it. if {[llength $lblock] > 0 || [llength $rblock] > 0} { set ::doingLine1 $lblockl set ::doingLine2 $rblockl | | | | | | 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 | } continue } # No change block anymore. If one just ended, display it. if {[llength $lblock] > 0 || [llength $rblock] > 0} { set ::doingLine1 $lblockl set ::doingLine2 $rblockl addMapLines $top [insertMatchingBlocks $top $lblock $rblock] set lblock {} set rblock {} } if {$lmode == "" && $rmode == ""} { insertLine $top 1 $lline $lstr insertLine $top 2 $rline $rstr incr leftc incr rightc addMapLines $top 1 continue } if {$lmode == "-"} { insertLine $top 1 $lline $lstr new1 emptyLine $top 2 incr leftc addMapLines $top 1 continue } if {$rmode == "+"} { insertLine $top 2 $rline $rstr new2 emptyLine $top 1 incr rightc addMapLines $top 1 continue } } } # Read a patch file and display it proc displayPatch {top} { |
︙ | ︙ | |||
1241 1242 1243 1244 1245 1246 1247 | set rightRE {^\+\+\+\s+(.*)$} } if {$state eq "newfile" && [regexp $leftRE $line -> sub]} { emptyLine $top 1 insertLine $top 1 "" $divider insertLine $top 1 "" $sub insertLine $top 1 "" $divider | < | < | 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 | set rightRE {^\+\+\+\s+(.*)$} } if {$state eq "newfile" && [regexp $leftRE $line -> sub]} { emptyLine $top 1 insertLine $top 1 "" $divider insertLine $top 1 "" $sub insertLine $top 1 "" $divider addChange $top 4 change 0 0 0 0 continue } if {$state eq "newfile" && [regexp $rightRE $line -> sub]} { emptyLine $top 2 insertLine $top 2 "" $divider insertLine $top 2 "" $sub insertLine $top 2 "" $divider |
︙ | ︙ | |||
1526 1527 1528 1529 1530 1531 1532 | # Clear up everything before starting processing foreach item {wLine1 wDiff1 wLine2 wDiff2} { set w $::widgets($top,$item) $w configure -state normal $w delete 1.0 end } | < | < | 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 | # Clear up everything before starting processing foreach item {wLine1 wDiff1 wLine2 wDiff2} { set w $::widgets($top,$item) $w configure -state normal $w delete 1.0 end } clearMap $top set ::HighLightCount 0 highLightChange $top -1 # Display a star during diff execution, to know when the internal # processing starts, and when the label is "valid". set ::widgets($top,eqLabel) "*" update idletasks if {$::diff($top,mode) eq "patch"} { |
︙ | ︙ | |||
1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 | } } } ##################################### # Map stuff ##################################### proc drawMap {top newh} { global Pref set oldh [map$top cget -height] if {$oldh == $newh} return | > > > > > > > > > > > > > > > > > > | 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 | } } } ##################################### # Map stuff ##################################### proc clearMap {top} { set ::diff($top,changes) {} set ::diff($top,mapMax) 0 drawMap $top -1 } proc addChange {top n tag line1 n1 line2 n2} { if {$tag ne ""} { lappend ::diff($top,changes) [list $::diff($top,mapMax) $n \ $tag $line1 $n1 $line2 $n2] } incr ::diff($top,mapMax) $n } proc addMapLines {top n} { incr ::diff($top,mapMax) $n } proc drawMap {top newh} { global Pref set oldh [map$top cget -height] if {$oldh == $newh} return |
︙ | ︙ | |||
3148 3149 3150 3151 3152 3153 3154 | $top.mo.mp add radiobutton -label "Blocks" -variable Pref(parse) -value 3 $top.mo.mp add separator $top.mo.mp add radiobutton -label "Characters" \ -variable Pref(lineparsewords) -value "0" $top.mo.mp add radiobutton -label "Words" \ -variable Pref(lineparsewords) -value "1" $top.mo.mp add separator | < < | 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 | $top.mo.mp add radiobutton -label "Blocks" -variable Pref(parse) -value 3 $top.mo.mp add separator $top.mo.mp add radiobutton -label "Characters" \ -variable Pref(lineparsewords) -value "0" $top.mo.mp add radiobutton -label "Words" \ -variable Pref(lineparsewords) -value "1" $top.mo.mp add separator $top.mo.mp add checkbutton -label "Mark last" -variable Pref(marklast) menu $top.mo.mc $top.mo.mc add radiobutton -label "Show all lines" \ -variable ::Pref(context) -value 0 $top.mo.mc add separator $top.mo.mc add radiobutton -label "Context 2 lines" \ |
︙ | ︙ | |||
3837 3838 3839 3840 3841 3842 3843 | } else { if {$info & 4} { set tag1 changed } else { set tag1 change } } | | < < < < < | 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 | } else { if {$info & 4} { set tag1 changed } else { set tag1 change } } addChange .dirdiff 1 $maptag 0 0 0 0 if {$df2 eq ""} { $dirdiff(wRight) insert end \n } else { if {[catch {set size [file size $df2]}]} { set size -1 set mtime 0 |
︙ | ︙ | |||
3954 3955 3956 3957 3958 3959 3960 | set dirdiff(leftMark) "" set dirdiff(rightMark) "" $dirdiff(wLeft) delete 1.0 end $dirdiff(wRight) delete 1.0 end set top .dirdiff busyCursor $top | < < | | 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 | set dirdiff(leftMark) "" set dirdiff(rightMark) "" $dirdiff(wLeft) delete 1.0 end $dirdiff(wRight) delete 1.0 end set top .dirdiff busyCursor $top clearMap $top update idletasks compareDirs $dirdiff(leftDir) $dirdiff(rightDir) normalCursor .dirdiff drawMap $top -1 } # Pick a directory for compare |
︙ | ︙ | |||
4577 4578 4579 4580 4581 4582 4583 | -smallblock : The default. Do block analysis on small blocks. -block : Full block analysis. This can be slow if there are large change blocks. -char : The analysis of changes can be done on either -word : character or word basis. -char is the default. | < < < | 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 | -smallblock : The default. Do block analysis on small blocks. -block : Full block analysis. This can be slow if there are large change blocks. -char : The analysis of changes can be done on either -word : character or word basis. -char is the default. -noignore : Don't ignore any whitespace. -b : Ignore space changes. Default. -w : Ignore all spaces. -conflict : Treat file as a merge conflict file and enter merge mode. -o <file> : Specify merge result output file. |
︙ | ︙ | |||
4648 4649 4650 4651 4652 4653 4654 | } elseif {$arg eq "-block"} { set Pref(parse) 3 } elseif {$arg eq "-char"} { set Pref(lineparsewords) 0 } elseif {$arg eq "-word"} { set Pref(lineparsewords) 1 } elseif {$arg eq "-2nd"} { | | | | 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 | } elseif {$arg eq "-block"} { set Pref(parse) 3 } elseif {$arg eq "-char"} { set Pref(lineparsewords) 0 } elseif {$arg eq "-word"} { set Pref(lineparsewords) 1 } elseif {$arg eq "-2nd"} { #set Pref(extralineparse) 1 } elseif {$arg eq "-no2nd"} { #set Pref(extralineparse) 0 } elseif {$arg eq "-limit"} { set nextArg limitlines } elseif {$arg eq "-nodiff"} { set noautodiff 1 } elseif {$arg eq "-dir"} { set dodir 1 } elseif {$arg eq "-clip"} { |
︙ | ︙ | |||
4918 4919 4920 4921 4922 4923 4924 | global Pref set Pref(fontsize) 8 set Pref(fontfamily) Courier set Pref(ignore) "-b" set Pref(parse) 2 set Pref(lineparsewords) 0 | < | 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 | global Pref set Pref(fontsize) 8 set Pref(fontfamily) Courier set Pref(ignore) "-b" set Pref(parse) 2 set Pref(lineparsewords) 0 set Pref(colorchange) red set Pref(colornew1) darkgreen set Pref(colornew2) blue set Pref(bgchange) #ffe0e0 set Pref(bgnew1) #a0ffa0 set Pref(bgnew2) #e0e0ff set Pref(context) 0 |
︙ | ︙ |