Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Added right mouse menu with file copy. Improved command line parsing. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ac0f28335707389272a012e46f259a4f |
User & Date: | spjutp 2000-07-25 11:39:05.000 |
Context
2000-08-24
| ||
12:29 | Improved block parsing. Added crlf option on windows. check-in: 77b90bc4e6 user: spjutp tags: trunk | |
2000-07-25
| ||
11:39 | Added right mouse menu with file copy. Improved command line parsing. check-in: ac0f283357 user: spjutp tags: trunk | |
11:33 | Some code cleanup. Use -translation crlf on windows. Added line numbers when printing. check-in: 61405d781b user: spjutp tags: trunk | |
Changes
Changes to dirdiff.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #!/bin/sh # the next line restarts using wish \ exec wish "$0" "$@" set thisScript [file join [pwd] [info script]] set thisDir [file dirname $thisScript] if {[file type $thisScript] == "link"} { set tmplink [file readlink $thisScript] set thisDir [file dirname [file join $thisDir $tmplink]] unset tmplink } if {$tcl_platform(platform) == "windows"} { package require dde } if {[info commands tk_chooseDirectory] == ""} { | > > > > > > > > | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #!/bin/sh # # Copyright (C) 1999-2000 Peter Spjuth # # the next line restarts using wish \ exec wish "$0" "$@" set thisScript [file join [pwd] [info script]] set thisDir [file dirname $thisScript] if {[file type $thisScript] == "link"} { set tmplink [file readlink $thisScript] set thisDir [file dirname [file join $thisDir $tmplink]] unset tmplink } if {$tcl_platform(platform) == "windows"} { package require dde } if {[info patchlevel] == "8.3.0"} { catch {source /home/spjutp/choosedir.tcl} } if {[info commands tk_chooseDirectory] == ""} { catch { source [file join $thisDir tkgetdir.tcl] rename tk_getDirectory tk_chooseDirectory } } #Compare file names proc fstrcmp {s1 s2} { #On Unix filenames are case sensitive if {$::tcl_platform(platform) == "unix"} { return [string compare $s1 $s2] } |
︙ | ︙ | |||
95 96 97 98 99 100 101 | 5 { #Ignore RCS set eq [expr {![catch {exec diff {--ignore-matching-lines=RCS: @(#) $Id} $file1 $file2} differr]}] } } return $eq } | | | | | > > > | | | | | | 103 104 105 106 107 108 109 110 111 112 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 | 5 { #Ignore RCS set eq [expr {![catch {exec diff {--ignore-matching-lines=RCS: @(#) $Id} $file1 $file2} differr]}] } } return $eq } # infoFiles: 1= noLeft 2 = noRight 4=left is dir 8= right is dir 16=diff proc listFiles {df1 df2 diff level} { global leftFiles rightFiles infoFiles lappend leftFiles $df1 lappend rightFiles $df2 set info 16 if {$df1 == ""} { incr info 1 } if {$df2 == ""} { incr info 2 } if {$df1 != ""} { set f1 [file split $df1] set i [expr {[llength $f1] - $level - 1}] set f1 [eval file join [lrange $f1 $i end]] } if {$df2 != ""} { set f2 [file split $df2] set i [expr {[llength $f2] - $level - 1}] set f2 [eval file join [lrange $f2 $i end]] } if {[file isdirectory $df1]} { append f1 / incr info 4 } if {[file isdirectory $df2]} { append f2 / incr info 8 } if {!$diff} { set tag2 "" incr info -16 } elseif {$df1 == ""} { set tag2 new2 } else { if {$info & 8} { set tag2 changed } else { set tag2 change } } if {$df2 == ""} { set tag1 new1 .t2 insert end \n } else { if {$info & 4} { set tag1 changed } else { set tag1 change } .t2 insert end [format "%-30s %8d %16s\n" $f2 [file size $df2] \ [clock format [file mtime $df2] -format "%Y-%m-%d %H:%M"]] \ $tag2 |
︙ | ︙ | |||
258 259 260 261 262 263 264 | proc selectFile {w x y} { global leftDir rightDir leftFiles rightFiles infoFiles Pref set row [expr {int([$w index @$x,$y]) - 1}] set lf [lindex $leftFiles $row] set rf [lindex $rightFiles $row] set i [lindex $infoFiles $row] | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | proc selectFile {w x y} { global leftDir rightDir leftFiles rightFiles infoFiles Pref set row [expr {int([$w index @$x,$y]) - 1}] set lf [lindex $leftFiles $row] set rf [lindex $rightFiles $row] set i [lindex $infoFiles $row] if {($i & 12) == 12} { # Both are dirs set leftDir $lf set rightDir $rf if {$Pref(autocompare)} doCompare } elseif {$i & 4} { # Left is dir set leftDir $lf if {$Pref(autocompare)} doCompare } elseif {$i & 8} { # Right is dir set rightDir $rf if {$Pref(autocompare)} doCompare } elseif {($i & 3) == 0} { # Both exists remoteDiff $lf $rf } } proc rightClick {w x y X Y} { global leftDir rightDir leftFiles rightFiles infoFiles Pref set row [expr {int([$w index @$x,$y]) - 1}] set lf [lindex $leftFiles $row] set rf [lindex $rightFiles $row] set i [lindex $infoFiles $row] destroy .m menu .m -tearoff 0 if {($i & 12) == 12} { # Both are dirs .m add command -label "Compare Directories" -command " [list set leftDir $lf] [list set rightDir $rf] [list if \$Pref(autocompare) "after idle doCompare"] " } elseif {$i & 4} { # Left is dir .m add command -label "Step down left directory" -command " [list set leftDir $lf] [list if \$Pref(autocompare) "after idle doCompare"] " } elseif {$i & 8} { # Right is dir .m add command -label "Step down right directory" -command " [list set rightDir $rf] [list if \$Pref(autocompare) "after idle doCompare"] " } elseif {($i & 3) == 0} { # Both exists .m add command -label "Compare Files" -command [list \ remoteDiff $lf $rf] } if {$w == ".t1" && ($i & 13) == 0} { .m add command -label "Copy File" -command [list \ copyFile $row right] } if {$w == ".t2" && ($i & 14) == 0} { .m add command -label "Copy File" -command [list \ copyFile $row left] } tk_popup .m $X $Y } proc copyFile {row to} { global leftDir rightDir leftFiles rightFiles infoFiles Pref if {$to == "left"} { set src [lindex $rightFiles $row] set n [expr {[string length $rightDir] + 1}] set dst [file join $leftDir [string range $src $n end]] } elseif {$to == "right"} { set src [lindex $leftFiles $row] set n [expr {[string length $leftDir] + 1}] set dst [file join $rightDir [string range $src $n end]] } else { error "Bad to argument to copyFile: $to" } if {[file exists $dst]} { if {[tk_messageBox -icon question -title "Copy file?" -message \ "Copy $src overwriting $dst ?" -type yesno] == "yes"} { file copy -force $src $dst } } else { if {[tk_messageBox -icon question -title "Copy file?" -message \ "Copy $src to $dst ?" -type yesno] == "yes"} { file copy $src $dst } } } proc remoteDiff {file1 file2} { global tcl_platform set cmd [list remoteDiff $file1 $file2] if {$tcl_platform(platform) == "unix"} { #send -async Diff $cmd |
︙ | ︙ | |||
415 416 417 418 419 420 421 422 423 424 425 426 427 428 | text .t2 -height 40 -width 60 -wrap none -yscrollcommand my_yscroll \ -xscrollcommand ".sbx2 set" -font myfont scrollbar .sbx2 -orient horizontal -command ".t2 xview" canvas .c -width 4 bind .t1 <Double-Button-1> "after idle selectFile .t1 %x %y" bind .t2 <Double-Button-1> "after idle selectFile .t2 %x %y" applyColor grid .fm - - - - -sticky we grid .fe1 x x .fe2 -sticky we grid .t1 .c .sby .t2 -sticky news grid .sbx1 x x .sbx2 -sticky we | > > | 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | text .t2 -height 40 -width 60 -wrap none -yscrollcommand my_yscroll \ -xscrollcommand ".sbx2 set" -font myfont scrollbar .sbx2 -orient horizontal -command ".t2 xview" canvas .c -width 4 bind .t1 <Double-Button-1> "after idle selectFile .t1 %x %y" bind .t2 <Double-Button-1> "after idle selectFile .t2 %x %y" bind .t1 <Button-3> "rightClick .t1 %x %y %X %Y" bind .t2 <Button-3> "rightClick .t2 %x %y %X %Y" applyColor grid .fm - - - - -sticky we grid .fe1 x x .fe2 -sticky we grid .t1 .c .sby .t2 -sticky news grid .sbx1 x x .sbx2 -sticky we |
︙ | ︙ | |||
452 453 454 455 456 457 458 | } } proc parseCommandLine {} { global argc argv leftDir rightDir Pref if {$argc == 2} { | | | | | > > > > > | > | 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | } } proc parseCommandLine {} { global argc argv leftDir rightDir Pref if {$argc == 2} { set leftDir [file join [pwd] [lindex $argv 0]] set rightDir [file join [pwd] [lindex $argv 1]] } elseif {$argc == 1} { set leftDir [file join [pwd] [lindex $argv 0]] set rightDir $leftDir } else { set leftDir [pwd] set rightDir [pwd] } } if {![winfo exists .fm]} { getOptions parseCommandLine makeDirDiffWin if {$leftDir != "" && $rightDir != "" && $leftDir != $rightDir} { update idletasks .e1 xview end .e2 xview end doCompare } } |