home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / komix / DATA.Z / ccsystem.tcl < prev    next >
Text File  |  1997-11-20  |  7KB  |  272 lines

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