User:Pieper:Merging

From NAMIC Wiki
Revision as of 15:26, 24 April 2008 by Pieper (talk | contribs) (New page: This simple script helps automate merging of a bunch of files using tkdiff. <pre> #!/bin/sh # the next line restarts using tclsh \ exec wish "$0" "$@" wm withdraw . set ::tkdiff "c...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This simple script helps automate merging of a bunch of files using tkdiff.


#!/bin/sh
# the next line restarts using tclsh \
    exec wish "$0" "$@"

wm withdraw .

set ::tkdiff "c:/Program Files (x86)/TkDiff/tkdiff.exe"

proc diffcopy {fileName} {
  puts "checking $fileName"
  set dest $fileName 
  set src c:/pieper/bwh/slicer3/EventBroker/Slicer3/$fileName

  if { [file isdirectory $src] } {
    puts "skipping directory $fileName"
    return
  }

  if { ![file exists $src] } {
    puts "no source file $fileName"
    return
  }

  set ret [catch [list exec diff $src $dest] res]
  if { $res == "" } {
    puts "no changes in $fileName"
    return
  }

  set ret [catch [list exec $::tkdiff $src $dest] res]

  set resp [tk_messageBox -message "copy \n\t$src \nto\n\t$dest\n?" -type yesno]

  if { $resp == "yes" } {
    puts "copying $src to $dest"
    file copy -force $src $dest
  }
}


foreach fileName $argv {
  diffcopy $fileName
}


exit