Eskil

Diff
Login

Differences From Artifact [10c3a0d790]:

To Artifact [58f36acf1b]:


1
2
3
4

5
6
7
8
9
10
11
1
2
3

4
5
6
7
8
9
10
11



-
+







#----------------------------------------------------------------------
#  Eskil, Directory diff section
#
#  Copyright (c) 1998-2005, Peter Spjuth  (peter.spjuth@space.se)
#  Copyright (c) 1998-2007, Peter Spjuth  (peter.spjuth@space.se)
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
54
55
56
57
58
59
60

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

80
81
82
83
84
85
86







+


















-







    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)
    # Different size is enough when doing binary compare
    if {$stat1(size) != $stat2(size) && $Pref(comparelevel) eq "1b" \
        && !$ignorekey} {
        return 0
    }
    # Same size and time is always considered equal
    if {$stat1(size) == $stat2(size) && $stat1(mtime) == $stat2(mtime)} {
	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
    }

    set ignorekey $Pref(dir,ignorekey)
    switch $Pref(comparelevel) {
        1b -
        1 { # Check contents internally
            set bufsz 65536
            set eq 1
            set ch1 [open $file1 r]
            set ch2 [open $file2 r]
230
231
232
233
234
235
236

237

238










239
240
241













242
243
244





















245





246















247
248
249
250
251
252
253
230
231
232
233
234
235
236
237

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



250
251
252
253
254
255
256
257
258
259
260
261
262
263


264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290

291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312







+
-
+

+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







		$tag1
    }
    lappend dirdiff(infoFiles) $info
}

# Returns the contents of a directory as a sorted list of file tails.
proc DirContents {dir} {
    global Pref
    set files [glob -tails -dir $dir -nocomplain * {.[a-zA-Z]*}]
    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]
                set controlled($name) 1
            }
    set files2 {}
    foreach file $files {
        # Simple static filter for now
            set files2 {}
            foreach file $files {
                if {[info exists controlled($file)]} {
                    lappend files2 $file
                }
            }
            set files $files2
        }
    }

    set files2 {}
    foreach file $files {
        # Apply filters
        if {[FileIsDirectory $file]} {
            if {$::Pref(nodir)} continue
            if {$file eq "CVS"} continue
            if {$Pref(nodir)} continue
            if {[llength $Pref(dir,incdirs)] == 0} {
                set allowed 1
            } else {
                set allowed 0
                foreach pat $Pref(dir,incdirs) {
                    if {[string match $pat $file]} {
                        set allowed 1
                        break
                    }
                }
            }
            if {$allowed} {
                foreach pat $Pref(dir,exdirs) {
                    if {[string match $pat $file]} {
                        set allowed 0
                        break
                    }
                }
            }
            if {!$allowed} continue
        } else {
            if {[llength $Pref(dir,incfiles)] == 0} {
                set allowed 1
            } else {
                set allowed 0
                foreach pat $Pref(dir,incfiles) {
            if {[string match "*.o" $file]} continue
                    if {[string match $pat $file]} {
                        set allowed 1
                        break
                    }
                }
            }
            if {$allowed} {
                foreach pat $Pref(dir,exfiles) {
                    if {[string match $pat $file]} {
                        set allowed 0
                        break
                    }
                }
            }
            if {!$allowed} continue
        }
        lappend files2 $file
    }

    return [Fsort $files2]
}

689
690
691
692
693
694
695





696
697
698
699
700
701
702
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766







+
+
+
+
+







    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 {} {
711
712
713
714
715
716
717





718
719
720
721
722
723
724
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793







+
+
+
+
+







        foreach item {
            recursive
            dir,onlydiffs
            nodir
            autocompare
            comparelevel
            dir,ignorekey
            dir,incfiles
            dir,exfiles
            dir,incdirs
            dir,exdirs
            dir,onlyrev
        } {
            set ::TmpPref($item) $::Pref($item)
        }
    }

    wm title $top "Eskil Directory Preferences"

744
745
746
747
748
749
750
751



















752
753
754
755
756
757
758
759
760
761

762
763
764
765
766
767
768
813
814
815
816
817
818
819

820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847

848
849
850
851
852
853
854
855







-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+









-
+







    checkbutton $opts.cb1 -variable TmpPref(dir,ignorekey) \
            -text "Ignore \$Keyword:\$"
    checkbutton $opts.cb2 -variable TmpPref(recursive)     -text "Recursive"
    checkbutton $opts.cb3 -variable TmpPref(dir,onlydiffs) -text "Diffs Only"
    checkbutton $opts.cb4 -variable TmpPref(nodir)         -text "No Directory"
    checkbutton $opts.cb5 -variable TmpPref(autocompare)   -text "Auto Compare"
    eval pack [winfo children $opts] -side top -anchor w 
    

    set filter [labelframe $top.filter -text "Filter" -padx 3 -pady 3]
    label $filter.l1 -text "Include Files" -anchor w
    entry $filter.e1 -width 20 -textvariable TmpPref(dir,incfiles)
    label $filter.l2 -text "Exclude Files" -anchor w
    entry $filter.e2 -width 20 -textvariable TmpPref(dir,exfiles)
    label $filter.l3 -text "Include Dirs" -anchor w
    entry $filter.e3 -width 20 -textvariable TmpPref(dir,incdirs)
    label $filter.l4 -text "Exclude Dirs" -anchor w
    entry $filter.e4 -width 20 -textvariable TmpPref(dir,exdirs)
    checkbutton $filter.cb1 -text "Only revision controlled" \
            -variable TmpPref(dir,onlyrev)
    grid $filter.l1 $filter.e1 -sticky we -padx 3 -pady 3
    grid $filter.l2 $filter.e2 -sticky we -padx 3 -pady 3
    grid $filter.l3 $filter.e3 -sticky we -padx 3 -pady 3
    grid $filter.l4 $filter.e4 -sticky we -padx 3 -pady 3
    grid $filter.cb1 - -sticky w -padx 3 -pady 3
    grid columnconfigure $filter 1 -weight 1

    set fb [frame $top.fb -padx 3 -pady 3]
    button $fb.ok -width 10 -text "Ok" \
            -command "ApplyDirDiffPref ; destroy $top"
    button $fb.ap -width 10 -text "Apply" -command ApplyDirDiffPref
    button $fb.ca -width 10 -text "Cancel" -command "destroy $top"
    grid $fb.ok $fb.ap $fb.ca -padx 3 -pady 3
    grid columnconfigure $fb {0 1 2} -uniform a -weight 1

    pack $fb -side bottom -fill x
    pack $check $opts -side top -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