77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
file stat $file1 stat1
file stat $file2 stat2
}
# If contents is not checked, same size is enough to be equal
if {$stat1(size) == $stat2(size) && $::Pref(dir,comparelevel) == 0} {
return 1
}
set anyPlugin [expr {$::eskil(.dirdiff,plugin) ne "" && \
[dict get $::eskil(.dirdiff,pluginpinfo) dir]}]
set ignorekey $::Pref(dir,ignorekey)
# Different size is enough when doing binary compare
if {$stat1(size) != $stat2(size) && $::Pref(dir,comparelevel) == 2 \
&& !$ignorekey && !$anyPlugin} {
return 0
}
# Same size and time is always considered equal
if {$stat1(size) == $stat2(size) && $stat1(mtime) == $stat2(mtime)} {
|
|
|
>
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
file stat $file1 stat1
file stat $file2 stat2
}
# If contents is not checked, same size is enough to be equal
if {$stat1(size) == $stat2(size) && $::Pref(dir,comparelevel) == 0} {
return 1
}
set anyPlugin [expr {$::eskil(.dirdiff,plugin,1) ne "" && \
[dict get $::eskil(.dirdiff,pluginpinfo,1) dir]}]
set ignorekey $::Pref(dir,ignorekey)
set nocase $::Pref(nocase)
# Different size is enough when doing binary compare
if {$stat1(size) != $stat2(size) && $::Pref(dir,comparelevel) == 2 \
&& !$ignorekey && !$anyPlugin} {
return 0
}
# Same size and time is always considered equal
if {$stat1(size) == $stat2(size) && $stat1(mtime) == $stat2(mtime)} {
|
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
if {$::Pref(dir,comparelevel) == 2} {
fconfigure $ch1 -translation binary
fconfigure $ch2 -translation binary
}
# Allow a plugin to do its thing
if {$anyPlugin} {
#puts "PLUGIN!"
$::eskil(.dirdiff,plugin) eval \
[list array set ::Pref [array get ::Pref]]
$::eskil(.dirdiff,plugin) eval [list set ::argv $::eskil(argv)]
interp share {} $ch1 $::eskil(.dirdiff,plugin)
interp share {} $ch2 $::eskil(.dirdiff,plugin)
set info1 [dict create name $file1 size $stat1(size)]
set info2 [dict create name $file2 size $stat2(size)]
set eq [$::eskil(.dirdiff,plugin) eval \
[list FileCompare $ch1 $ch2 $info1 $info2]]
set allow [dict get $::eskil(.dirdiff,pluginpinfo) allow]
if {$allow} {
$::eskil(.dirdiff,plugin) eval close $ch1
$::eskil(.dirdiff,plugin) eval close $ch2
} else {
$::eskil(.dirdiff,plugin) invokehidden close $ch1
$::eskil(.dirdiff,plugin) invokehidden close $ch2
}
}
if {$ignorekey} {
# Assume that all keywords are in the first block
set f1 [read $ch1 $bufsz]
set f2 [read $ch2 $bufsz]
regsub -all {\$\w+:[^\$]*\$} $f1 {} f1
regsub -all {\$\w+:[^\$]*\$} $f2 {} f2
# Compensate for any change in length
if {[string length $f1] < [string length $f2]} {
append f1 [read $ch1 [expr {[string length $f2] - [string length $f1]}]]
}
if {[string length $f2] < [string length $f1]} {
append f2 [read $ch2 [expr {[string length $f1] - [string length $f2]}]]
}
if {![string equal $f1 $f2]} {
set eq 0
}
}
while {$eq == 2 && ![eof $ch1] && ![eof $ch2]} {
set f1 [read $ch1 $bufsz]
set f2 [read $ch2 $bufsz]
if {![string equal $f1 $f2]} {
set eq 0
}
}
if {$eq == 2 && (![eof $ch1] || ![eof $ch2])} {
set eq 0
}
# Errors during close are not interesting
catch {close $ch1}
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
|
|
>
>
>
>
>
>
|
|
>
|
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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
|
if {$::Pref(dir,comparelevel) == 2} {
fconfigure $ch1 -translation binary
fconfigure $ch2 -translation binary
}
# Allow a plugin to do its thing
if {$anyPlugin} {
#puts "PLUGIN!"
$::eskil(.dirdiff,plugin,1) eval \
[list array set ::Pref [array get ::Pref]]
$::eskil(.dirdiff,plugin,1) eval [list set ::argv $::eskil(argv)]
interp share {} $ch1 $::eskil(.dirdiff,plugin,1)
interp share {} $ch2 $::eskil(.dirdiff,plugin,1)
set info1 [dict create name $file1 size $stat1(size)]
set info2 [dict create name $file2 size $stat2(size)]
set eq [$::eskil(.dirdiff,plugin,1) eval \
[list FileCompare $ch1 $ch2 $info1 $info2]]
set allow [dict get $::eskil(.dirdiff,pluginpinfo,1) allow]
if {$allow} {
$::eskil(.dirdiff,plugin,1) eval close $ch1
$::eskil(.dirdiff,plugin,1) eval close $ch2
} else {
$::eskil(.dirdiff,plugin,1) invokehidden close $ch1
$::eskil(.dirdiff,plugin,1) invokehidden close $ch2
}
}
if {$ignorekey} {
# Assume that all keywords are in the first block
set f1 [read $ch1 $bufsz]
set f2 [read $ch2 $bufsz]
regsub -all {\$\w+:[^\$]*\$} $f1 {} f1
regsub -all {\$\w+:[^\$]*\$} $f2 {} f2
# Compensate for any change in length
if {[string length $f1] < [string length $f2]} {
append f1 [read $ch1 [expr {[string length $f2] - [string length $f1]}]]
}
if {[string length $f2] < [string length $f1]} {
append f2 [read $ch2 [expr {[string length $f1] - [string length $f2]}]]
}
if {$nocase} {
if {![string equal -nocase $f1 $f2]} {
set eq 0
}
} else {
if {![string equal $f1 $f2]} {
set eq 0
}
}
}
while {$eq == 2 && ![eof $ch1] && ![eof $ch2]} {
set f1 [read $ch1 $bufsz]
set f2 [read $ch2 $bufsz]
if {$nocase} {
if {![string equal -nocase $f1 $f2]} {
set eq 0
}
} else {
if {![string equal $f1 $f2]} {
set eq 0
}
}
}
if {$eq == 2 && (![eof $ch1] || ![eof $ch2])} {
set eq 0
}
# Errors during close are not interesting
catch {close $ch1}
|
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
|
proc makeDirDiffWin {} {
if {![info exists ::dirdiff(leftDir)]} {
set ::dirdiff(leftDir) ""
}
if {![info exists ::dirdiff(rightDir)]} {
set ::dirdiff(rightDir) ""
}
set ::eskil(.dirdiff,plugin) ""
foreach {item val} $::eskil(defaultopts) {
set ::eskil(.dirdiff,$item) $val
}
# Support -r for directory diff
set revs {}
array set opts $::eskil(defaultopts)
|
>
|
|
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
|
proc makeDirDiffWin {} {
if {![info exists ::dirdiff(leftDir)]} {
set ::dirdiff(leftDir) ""
}
if {![info exists ::dirdiff(rightDir)]} {
set ::dirdiff(rightDir) ""
}
# TODO, multi plugin for dirdiff?
set ::eskil(.dirdiff,plugin,1) ""
foreach {item val} $::eskil(defaultopts) {
set ::eskil(.dirdiff,$item) $val
}
# Support -r for directory diff
set revs {}
array set opts $::eskil(defaultopts)
|