Eskil

Check-in [4c8f6d2ad7]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Started on separator support for tables
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4c8f6d2ad7838d567a1b0e741a36a9c486232ee0
User & Date: peter 2015-03-15 23:56:49.461
Context
2015-03-16
00:08
Code restructure check-in: be75239ba7 user: peter tags: trunk
2015-03-15
23:56
Started on separator support for tables check-in: 4c8f6d2ad7 user: peter tags: trunk
21:16
Extended Mercurial support to commit, revert, log and directory diff. check-in: 89f6168b65 user: peter tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/eskil.tcl.
374
375
376
377
378
379
380


















































381
382
383
384
385
386
387
    if {$highlight} {
        $::widgets($top,wLine$n) insert end "\n" hl$::HighLightCount
    } else {
        $::widgets($top,wLine$n) insert end "*****\n"
    }
    $::widgets($top,wDiff$n) insert end "\n" padding
}



















































# Insert one line in each text widget.
# Mark them as changed, and optionally parse them.
proc insertMatchingLines {top line1 line2} {
    global doingLine1 doingLine2

    # FIXA: fully implement filter







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
    if {$highlight} {
        $::widgets($top,wLine$n) insert end "\n" hl$::HighLightCount
    } else {
        $::widgets($top,wLine$n) insert end "*****\n"
    }
    $::widgets($top,wDiff$n) insert end "\n" padding
}

# Helper to take care of -sep case
# This can be used when diffing e.g. a CSV file.
# Each column will be handled separately, so differences will never be shown
# crossing a separator
proc diffWithSeparator {RE line1 line2 opts} {
    set ixs1 [regexp -all -inline -indices -- $RE $line1]
    set ixs2 [regexp -all -inline -indices -- $RE $line2]
    # Fake a separator after end of line, makes the loop below simpler
    lappend ixs1 [list [string length $line1] [string length $line1]]
    lappend ixs2 [list [string length $line2] [string length $line2]]
    set res {}
    set s1 0
    set s2 0
    foreach ix1 $ixs1 ix2 $ixs2 {
        # Handle if one index list is shorter
        if {$ix1 eq ""} {
            set str1 ""
            set sep1 ""
        } else {
            lassign $ix1 e1 ns1
            incr e1 -1
            set str1 [string range $line1 $s1 $e1]
            set sep1 [string range $line1 {*}$ix1]
        }
        if {$ix2 eq ""} {
            set str2 ""
            set sep2 ""
        } else {
            lassign $ix2 e2 ns2
            incr e2 -1
            set str2 [string range $line2 $s2 $e2]
            set sep2 [string range $line2 {*}$ix2]
        }
        if {$str1 eq $str2} {
            # Could be better at merging equalites...
            lappend res "" "" $str1$sep1 $str2$sep2
        } else {
            set r [DiffUtil::diffStrings {*}$opts $str1 $str2]
            # Could be better at merging equalites...
            lappend res "" "" {*}$r "" "" $sep1 $sep2
        }
        set s1 [expr {$ns1 + 1}]
        set s2 [expr {$ns2 + 1}]
    }
    # Remove the extra pair added in the loop
    set res [lrange $res 2 end]
    #puts "RES $res"
    return $res
}

# Insert one line in each text widget.
# Mark them as changed, and optionally parse them.
proc insertMatchingLines {top line1 line2} {
    global doingLine1 doingLine2

    # FIXA: fully implement filter
397
398
399
400
401
402
403




404

405
406
407
408
409
410
411
        set ::eskil(filterflag) 0
    }

    if {$::Pref(parse) != 0} {
        set opts $::Pref(ignore)
        if {$::Pref(nocase)} {lappend opts -nocase}
        if {$::Pref(lineparsewords)} {lappend opts -words}




        set res [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"







>
>
>
>
|
>







447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
        set ::eskil(filterflag) 0
    }

    if {$::Pref(parse) != 0} {
        set opts $::Pref(ignore)
        if {$::Pref(nocase)} {lappend opts -nocase}
        if {$::Pref(lineparsewords)} {lappend opts -words}
        if {$::eskil($top,separator) ne ""} {
            set res [diffWithSeparator $::eskil($top,separator) $line1 $line2 \
                             $opts]
        } else {
            set res [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"
2798
2799
2800
2801
2802
2803
2804

2805
2806
2807
2808
2809
2810
2811
proc initDiffData {top} {
    set ::eskil($top,leftOK) 0
    set ::eskil($top,rightOK) 0
    set ::eskil($top,mode) ""
    set ::eskil($top,printFile) ""
    set ::eskil($top,mergeFile) ""
    set ::eskil($top,ancestorFile) ""

    set ::eskil($top,conflictFile) ""
    set ::eskil($top,limitlines) 0
    set ::eskil($top,plugin) ""

    # Copy the collected options from command line
    foreach {item val} $::eskil(defaultopts) {
        set ::eskil($top,$item) $val







>







2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
proc initDiffData {top} {
    set ::eskil($top,leftOK) 0
    set ::eskil($top,rightOK) 0
    set ::eskil($top,mode) ""
    set ::eskil($top,printFile) ""
    set ::eskil($top,mergeFile) ""
    set ::eskil($top,ancestorFile) ""
    set ::eskil($top,separator) ""
    set ::eskil($top,conflictFile) ""
    set ::eskil($top,limitlines) 0
    set ::eskil($top,plugin) ""

    # Copy the collected options from command line
    foreach {item val} $::eskil(defaultopts) {
        set ::eskil($top,$item) $val
3907
3908
3909
3910
3911
3912
3913


3914
3915
3916
3917
3918
3919
3920

    foreach arg $::eskil(argv) {
        if {$nextArg != ""} {
            if {$nextArg eq "mergeFile"} {
                set opts(mergeFile) [file join [pwd] $arg]
            } elseif {$nextArg eq "ancestorFile"} {
                set opts(ancestorFile) [file join [pwd] $arg]


            } elseif {$nextArg eq "printFile"} {
                set opts(printFile) [file join [pwd] $arg]
            } elseif {$nextArg eq "printFont"} {
                set ::Pref(printFont) $arg
            } elseif {$nextArg eq "printHeaderSize"} {
                if {![string is double -strict $arg] || $arg <= 0} {
                    puts "Argument -printHeaderSize must be a positive number"







>
>







3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978

    foreach arg $::eskil(argv) {
        if {$nextArg != ""} {
            if {$nextArg eq "mergeFile"} {
                set opts(mergeFile) [file join [pwd] $arg]
            } elseif {$nextArg eq "ancestorFile"} {
                set opts(ancestorFile) [file join [pwd] $arg]
            } elseif {$nextArg eq "separator"} {
                set opts(separator) $arg
            } elseif {$nextArg eq "printFile"} {
                set opts(printFile) [file join [pwd] $arg]
            } elseif {$nextArg eq "printFont"} {
                set ::Pref(printFont) $arg
            } elseif {$nextArg eq "printHeaderSize"} {
                if {![string is double -strict $arg] || $arg <= 0} {
                    puts "Argument -printHeaderSize must be a positive number"
4100
4101
4102
4103
4104
4105
4106


4107
4108
4109
4110
4111
4112
4113
            }
        } elseif {$arg eq "-o"} {
            set nextArg mergeFile
        } elseif {$arg eq "-a"} {
            set nextArg ancestorFile
            # Default is no ignore on three-way merge
            set ::Pref(ignore) " "


        } elseif {$arg eq "-fine"} {
            set ::Pref(finegrainchunks) 1
        } elseif {$arg eq "-r"} {
            set nextArg revision
        } elseif {$arg eq "-debug"} {
            set ::eskil(debug) 1
        } elseif {$arg eq "-svn"} {







>
>







4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
            }
        } elseif {$arg eq "-o"} {
            set nextArg mergeFile
        } elseif {$arg eq "-a"} {
            set nextArg ancestorFile
            # Default is no ignore on three-way merge
            set ::Pref(ignore) " "
        } elseif {$arg eq "-sep"} {
            set nextArg separator
        } elseif {$arg eq "-fine"} {
            set ::Pref(finegrainchunks) 1
        } elseif {$arg eq "-r"} {
            set nextArg revision
        } elseif {$arg eq "-debug"} {
            set ::eskil(debug) 1
        } elseif {$arg eq "-svn"} {