Eskil

Check-in [052b55abac]
Login

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

Overview
Comment:Consider dirs equal, thus not showing up in only diffs. Check dirdiff filters for listness.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 052b55abac7494949c12ac727783c4e0429ce21e
User & Date: peter 2007-01-30 10:13:41.000
Context
2007-02-17
04:26
Removed dependency on external pdf4tcl. check-in: 76569fcd88 user: peter tags: trunk
2007-01-30
10:13
Consider dirs equal, thus not showing up in only diffs. Check dirdiff filters for listness. check-in: 052b55abac user: peter tags: trunk
10:11
*** empty log message *** check-in: 4f9b7b7807 user: peter tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/dirdiff.tcl.
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53
54


55
56
57
58
59
60
61
    if {$::tcl_platform(platform) eq "unix"} {
	return [lsort $l]
    }
    # Case insensitive on windows
    lsort -dictionary $l
}

# Compare two files

proc CompareFiles {file1 file2} {
    global Pref
    if {[catch {file stat $file1 stat1}]} {
        return 0
    }
    if {[catch {file stat $file2 stat2}]} {
        return 0
    }

    # Same type?
    if {[FileIsDirectory $file1] != [FileIsDirectory $file2]} {


	return 0
    }
    # If contents is not checked, same size is enough to be equal
    if {$stat1(size) == $stat2(size) && $Pref(comparelevel) == 0} {
        return 1
    }
    set ignorekey $Pref(dir,ignorekey)







|
>










|
>
>







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
    if {$::tcl_platform(platform) eq "unix"} {
	return [lsort $l]
    }
    # Case insensitive on windows
    lsort -dictionary $l
}

# Compare two files or dirs
# Return true if equal
proc CompareFiles {file1 file2} {
    global Pref
    if {[catch {file stat $file1 stat1}]} {
        return 0
    }
    if {[catch {file stat $file2 stat2}]} {
        return 0
    }

    # Same type?
    set isdir1 [FileIsDirectory $file1]
    set isdir2 [FileIsDirectory $file2]
    if {$isdir1 != $isdir2} {
	return 0
    }
    # If contents is not checked, same size is enough to be equal
    if {$stat1(size) == $stat2(size) && $Pref(comparelevel) == 0} {
        return 1
    }
    set ignorekey $Pref(dir,ignorekey)
69
70
71
72
73
74
75
76

77
78
79
80
81
82
83
84
	return 1
    }
    # Don't check further if contents should not be checked
    if {$Pref(comparelevel) == 0} {
        return 0
    }
    # Don't check further if any is a directory
    if {[FileIsDirectory $file1] || [FileIsDirectory $file2]} {

	return 0
    }

    switch $Pref(comparelevel) {
        1b -
        1 { # Check contents internally
            set bufsz 65536
            set eq 1







|
>
|







72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
	return 1
    }
    # Don't check further if contents should not be checked
    if {$Pref(comparelevel) == 0} {
        return 0
    }
    # Don't check further if any is a directory
    if {$isdir1 || $isdir2} {
        # Consider dirs equal until we implement something recursive
	return 1
    }

    switch $Pref(comparelevel) {
        1b -
        1 { # Check contents internally
            set bufsz 65536
            set eq 1
234
235
236
237
238
239
240

241
242
243
244
245
246
247

# Returns the contents of a directory as a sorted list of file tails.
proc DirContents {dir} {
    global Pref
    set files [glob -tails -directory $dir -nocomplain * {.[a-zA-Z]*}]

    if {$Pref(dir,onlyrev)} {

        set entries [file join $dir CVS Entries]
        if {[file exists $entries]} {
            set ch [open $entries r]
            set data [read $ch]
            close $ch
            foreach line [split $data \n] {
                set name [lindex [split $line /] 1]







>







238
239
240
241
242
243
244
245
246
247
248
249
250
251
252

# Returns the contents of a directory as a sorted list of file tails.
proc DirContents {dir} {
    global Pref
    set files [glob -tails -directory $dir -nocomplain * {.[a-zA-Z]*}]

    if {$Pref(dir,onlyrev)} {
        # FIXA: move to rev and make general for other systems
        set entries [file join $dir CVS Entries]
        if {[file exists $entries]} {
            set ch [open $entries r]
            set data [read $ch]
            close $ch
            foreach line [split $data \n] {
                set name [lindex [split $line /] 1]
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
            }
	    switch -- $apa {
		0 {
		    set diff [expr {![CompareFiles $df1 $df2]}]
		    if {$diff || !$Pref(dir,onlydiffs)} {
			ListFiles $df1 $df2 $diff $level
		    }
                    # FIXA CVS should be filtered properly
		    if {[FileIsDirectory $df1] && [FileIsDirectory $df2] && \
			    $Pref(recursive) && [file tail $df1] != "CVS"} {
			CompareDirs $df1 $df2 [expr {$level + 1}]
		    }
		    incr p1
		    incr p2
		}
		-1 {
		    ListFiles $df1 "" 0 $level







|

|







339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
            }
	    switch -- $apa {
		0 {
		    set diff [expr {![CompareFiles $df1 $df2]}]
		    if {$diff || !$Pref(dir,onlydiffs)} {
			ListFiles $df1 $df2 $diff $level
		    }
                    # Optionally recurse
		    if {[FileIsDirectory $df1] && [FileIsDirectory $df2] && \
			    $Pref(recursive)} {
			CompareDirs $df1 $df2 [expr {$level + 1}]
		    }
		    incr p1
		    incr p2
		}
		-1 {
		    ListFiles $df1 "" 0 $level
748
749
750
751
752
753
754






755
756
757
758
759
760




761
762
763
764
765
766
767
    foreach item {
        recursive
        dir,onlydiffs
        nodir
        autocompare
        comparelevel
        dir,ignorekey






        dir,incfiles
        dir,exfiles
        dir,incdirs
        dir,exdirs
        dir,onlyrev
    } {




        set ::Pref($item) $::TmpPref($item)
    }
}

# Create directory diff preferences window.
proc makeDirDiffPrefWin {} {
    set top .dirdiffprefs







>
>
>
>
>
>




<

>
>
>
>







753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769

770
771
772
773
774
775
776
777
778
779
780
781
    foreach item {
        recursive
        dir,onlydiffs
        nodir
        autocompare
        comparelevel
        dir,ignorekey
        dir,onlyrev
    } {
        set ::Pref($item) $::TmpPref($item)
    }
    # Handle preferences that must be a list
    foreach item {
        dir,incfiles
        dir,exfiles
        dir,incdirs
        dir,exdirs

    } {
        # Force a split to make sure the list is valid
        if {[catch {llength $::TmpPref($item)}]} {
            set ::TmpPref($item) [regexp -all -inline {\S+} $::TmpPref($item)]
        }
        set ::Pref($item) $::TmpPref($item)
    }
}

# Create directory diff preferences window.
proc makeDirDiffPrefWin {} {
    set top .dirdiffprefs
845
846
847
848
849
850
851


852
853
854
855
856
857
858
    grid columnconfigure $fb {0 1 2} -uniform a -weight 1

    pack $fb -side bottom -fill x
    pack $check $opts $filter -side top -fill x
}

# Experimental...


proc makeRegSubWin {} {
    set top .ddregsub
    if {[winfo exists $top] && [winfo toplevel $top] eq $top} {
        raise $top
        focus -force $top
        return
    } else {







>
>







859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
    grid columnconfigure $fb {0 1 2} -uniform a -weight 1

    pack $fb -side bottom -fill x
    pack $check $opts $filter -side top -fill x
}

# Experimental...
#preprocess filter på namnen så man kan jämföra bibliotek
#med ändrade namn.
proc makeRegSubWin {} {
    set top .ddregsub
    if {[winfo exists $top] && [winfo toplevel $top] eq $top} {
        raise $top
        focus -force $top
        return
    } else {