home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / ccsystem.tcl < prev    next >
Text File  |  1997-05-23  |  6KB  |  252 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1997
  4. #
  5. #      File:           @(#)ccsystem.tcl    /main/hindenburg/7
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)ccsystem.tcl    /main/hindenburg/7   23 May 1997 Copyright 1997 Cayenne Software Inc.
  10.  
  11. # Start user added include file section
  12. require platform.tcl
  13. # End user added include file section
  14.  
  15. require_module_file "vssystem.tcl" vcm
  16.  
  17. # This class represents a ClearCase aware system.
  18.  
  19. Class CCSystem : {VSSystem} {
  20.     constructor
  21.     method destructor
  22.     method vsFileUserPath
  23.     method vsFileVSPath
  24.     method vsUserPath
  25.     method vsVsPath
  26.     method fileList
  27.     method fileExists
  28.     method move
  29. }
  30.  
  31. constructor CCSystem {class this name} {
  32.     set this [VSSystem::constructor $class $this $name]
  33.     # Start constructor user section
  34.     # End constructor user section
  35.     return $this
  36. }
  37.  
  38. method CCSystem::destructor {this} {
  39.     # Start destructor user section
  40.     # End destructor user section
  41.     $this VSSystem::destructor
  42. }
  43.  
  44.  
  45. # Use vsFileVSPath and prepend view information.
  46. #
  47. method CCSystem::vsFileUserPath {this name type} {
  48.     set vobPath [$this vsFileVSPath $name $type]
  49.     return [CCSystem::viewPath $vobPath]
  50. }
  51.  
  52.  
  53. # Get system path through vsObjectVSPath and append file name.
  54. #
  55. method CCSystem::vsFileVSPath {this name type} {
  56.     set systemPath [CCSystem::vsObjectVSPath $this]
  57.     set filePath [path_name concat $systemPath [$this getFileName $name $type]]
  58.     return $filePath
  59. }
  60.  
  61. proc CCSystem::createVSPath {path} {
  62.     VSSystem::createVSPath CCSystem $path
  63. }
  64.  
  65. proc CCSystem::createUserPath {path} {
  66.     VSSystem::createUserPath CCSystem $path
  67. }
  68.  
  69.  
  70. # Use vsObjectVSPath and prepend view information to
  71. # make view-extended pathname.
  72. #
  73. proc CCSystem::vsObjectUserPath {object} {
  74.     set vobPath [CCSystem::vsObjectVSPath $object]
  75.     return [CCSystem::viewPath $vobPath]
  76. }
  77.  
  78.  
  79. # Default implementation: return path
  80. # of Object using the builtin path method.
  81. #
  82. proc CCSystem::vsObjectVSPath {object} {
  83.     # this is ugly, but necessary
  84.     if [$object isA SystemVersion] {
  85.     set vobPath [$object SystemVersion::path]
  86.     } elseif [$object isA ConfigVersion] {
  87.     # sport7 only 
  88.     set vobPath [$object ConfigVersion::path]
  89.     } else {
  90.     set vobPath [$object path]
  91.     }
  92.     return $vobPath
  93. }
  94.  
  95.  
  96. # Return user path of this system using
  97. # vsObjectUserPath.
  98. #
  99. method CCSystem::vsUserPath {this} {
  100.     return [CCSystem::vsObjectUserPath $this]
  101. }
  102.  
  103.  
  104. # Return vcm path of this system using
  105. # vsObjectVSPath.
  106. #
  107. method CCSystem::vsVsPath {this} {
  108.     return [CCSystem::vsObjectVSPath $this]
  109. }
  110.  
  111.  
  112. # Returns a list of ClearCase files found
  113. # in the directories specified by pathList.
  114. #
  115. method CCSystem::fileList {this pathList} {
  116.     return [CCCommand::shortListing $pathList]
  117. }
  118.  
  119. proc CCSystem::renameVSDirectory {oldPath newPath} {
  120.     set dir [path_name directory $oldPath]
  121.  
  122.     # check out directory if necessary
  123.     if  { ![CCSystem::checkOutDirectory $dir \
  124.         "Checked out by ObjectTeam for directory rename"] } {
  125.     return 0
  126.     }    
  127.  
  128.     set renameCommand [CCCommand::rename $oldPath $newPath]
  129.     return [vsCommandHandler execute $renameCommand]
  130. }
  131.  
  132.  
  133. # Make a view path of the indicated vobPath.
  134. #
  135. proc CCSystem::viewPath {vobPath} {
  136.     set view [m4_var get M4_ccase_view]
  137.  
  138.     if { $view == "" } {
  139.     return $vobPath
  140.     }
  141.  
  142.     if $win95 {
  143.     set viewPath [path_name concat M: $view]
  144.     } else {
  145.     set viewPath [path_name concat /view $view]
  146.     }
  147.     return "$viewPath$vobPath"
  148. }
  149.  
  150.  
  151. # Do nothing: ClearCase directories are always
  152. # created in User env.
  153. #
  154. proc CCSystem::createVSDirectory {path} {
  155. }
  156.  
  157.  
  158. # Create specified directory in current view as
  159. # ClearCase directory element.
  160. # All components except the new one must already exist.
  161. #
  162. proc CCSystem::createUserDirectory {path} {
  163.     set dir [path_name directory $path]
  164.  
  165.     # check out directory if necessary
  166.     if  { ![CCSystem::checkOutDirectory $dir \
  167.         "Checked out by ObjectTeam for directory creation"] } {
  168.     return 0
  169.     }
  170.  
  171.     set comment "Created by ObjectTeam"
  172.     set mkdirCommand [CCCommand::createElem $path directory $comment]
  173.     return [vsCommandHandler execute $mkdirCommand]
  174. }
  175.  
  176.  
  177. # Return whether the given user path indicates
  178. # a ClearCase directory.
  179. #
  180. proc CCSystem::directoryExists {path} {
  181.     if { ![file isdirectory $path] } {
  182.     return 0
  183.     }
  184.  
  185.     return [CCCommand::existsInVob $path]
  186. }
  187.  
  188.  
  189. # If the specified directory is not checked out try to get
  190. # a reserved checkout with the specified comment.
  191. # Returns 1 on success, 0 on failure.
  192. #
  193. proc CCSystem::checkOutDirectory {directory comment} {
  194.     if { ![CCCommand::isCheckedOut $directory] } {
  195.     set checkoutCommand [CCCommand::checkOut $directory $comment 1]
  196.     return [vsCommandHandler execute $checkoutCommand]
  197.     }
  198.     return 1
  199. }
  200.  
  201.  
  202. # Returns whether the file with the given name and type exists in the VCM
  203. # environment.
  204. #
  205. method CCSystem::fileExists {this name type} {
  206.     set filePath [$this vsFileUserPath $name $type]
  207.     return [file exists $filePath]
  208. }
  209.  
  210.  
  211. # Move specified file to this system and return
  212. # resulting object on success.
  213. #
  214. method CCSystem::move {this vsFile} {
  215.      # move if source system is ClearCase
  216.     if [[$vsFile systemVersion] isA CCSystem] {
  217.     set destDir [$this path]
  218.     # create directory if necessary
  219.     if { ![file isdirectory $destDir] } {
  220.         if { ![CCSystem::createUserPath $destDir] } {
  221.         return 0
  222.         }
  223.     }
  224.  
  225.     # check out destination directory if necessary
  226.     if  { ![CCSystem::checkOutDirectory $destDir \
  227.         "Checked out by ObjectTeam for file move"] } {
  228.         return 0
  229.     }
  230.  
  231.     # check out source directory if necessary
  232.     set srcDir [path_name directory [$vsFile path]]
  233.     if  { ![CCSystem::checkOutDirectory $srcDir \
  234.         "Checked out by ObjectTeam for file move"] } {
  235.         return 0
  236.     }
  237.     set renameCommand [CCCommand::rename [$vsFile path] $destDir]
  238.     return [vsCommandHandler execute $renameCommand]
  239.     }
  240.  
  241.     # source is not clearcase: copy and delete
  242.     if { [$this VSSystem::copy $vsFile] != "" } {
  243.     return [$vsFile removeFromVS]
  244.     }
  245.  
  246.     return 0
  247. }
  248.  
  249. # Do not delete this line -- regeneration end marker
  250.  
  251.