home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / utility / misc / master / batch / merge.bat < prev    next >
DOS Batch File  |  1989-08-20  |  2KB  |  86 lines

  1. # Merge two source directories. Ask user if we find differences, which version
  2. # he wants to use. Eventually create a context-diff for some files.
  3.  
  4. if "$2" == "" {
  5.     rem Usage: $0 old-dir new-dir.
  6.     rem   Not: $0 '$1' '$2'.
  7.     quit 1
  8. }
  9.  
  10. VARSIZE 50000
  11.  
  12. rem Merging sources from $1 and $2
  13. rem Phase 1 (removing identical entries - using comp)
  14.  
  15. if not exist phase_1.mrg {
  16.     files -50000 $2 => sources
  17.     foreach file in sources do
  18.         if exist $1/$file {
  19.             if not exec "comp -qs $1/$file $2/$file > NUL:" {
  20.                 rm -q $1/$file
  21.                 rem Erased $1/$file.
  22.             }
  23.         }
  24.     endfor
  25.     touch -q phase_1.mrg
  26. }
  27.  
  28. rem Phase 2 (removing similar entries - using /bin/diff)
  29.  
  30. if not exist phase_2.mrg {
  31. #    files -50000 $2 => sources
  32. #    foreach file in sources do
  33. #        if exist $1/$file {
  34. #            if not exec "/bin/diff -b $1/$file $2/$file" {
  35. #                rm -q $1/$file
  36. #                rem Erased $1/$file.
  37. #            }
  38. #        }
  39. #    endfor
  40.     touch -q phase_2.mrg
  41. }
  42.  
  43. rem Phase 3 (user interaction)
  44. if not exist phase_3.mrg {
  45.     files -50000 $2 => sources
  46.     foreach file in sources do
  47.         if exist $1/$file {
  48.             /bin/diff -c $1/$file $2/$file|
  49.             get "Take \epN\eqew version, \epO\eqld version, \epS\eqkip or \epC\eqontext diff ? " answer
  50.             if answer == 'n' {
  51.                 rm -q $1/$file
  52.                 rem Erased $1/$file.
  53.             } else if answer == 'o' {
  54.                 mv -qo $1/$file $2/$file
  55.                 rem Substituted $2/$file with old version $1/$file.
  56.             } else if answer == 'c' {
  57.                 if not exist $2/PATCHES {
  58.                     touch -q $2/PATCHES
  59.                 }
  60.                 /bin/diff -c1 $1/$file $2/$file >> $2/PATCHES
  61.             } else {
  62.                 rem Skipping $file.
  63.             }
  64. #        } else {
  65. #            rem Old file $1/$file is not found in new version.
  66. #            get "\epG\eqet it, \epE\eqrase or \epS\eqkip ? " answer
  67. #            if answer == 'g' {
  68. #                mv -q $1/$file $2/$file
  69. #                rem Added $1/$file as new file $2/$file.
  70. #            } else if answer == 'e' {
  71. #                rm -q $1/$file
  72. #                rem Erased $1/$file.
  73. #            } else {
  74. #                rem Skipping $1/$file.
  75. #            }
  76.         }
  77.     endfor
  78.     touch -q phase_3.mrg
  79. }
  80.  
  81. rm -q phase_[1-3].mrg
  82.  
  83. rem Merging completed.
  84.  
  85. noVARSIZE
  86.