home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1997
- #
- # File: @(#)ccsystem.tcl /main/hindenburg/7
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)ccsystem.tcl /main/hindenburg/7 23 May 1997 Copyright 1997 Cayenne Software Inc.
-
- # Start user added include file section
- require platform.tcl
- # End user added include file section
-
- require_module_file "vssystem.tcl" vcm
-
- # This class represents a ClearCase aware system.
-
- Class CCSystem : {VSSystem} {
- constructor
- method destructor
- method vsFileUserPath
- method vsFileVSPath
- method vsUserPath
- method vsVsPath
- method fileList
- method fileExists
- method move
- }
-
- constructor CCSystem {class this name} {
- set this [VSSystem::constructor $class $this $name]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CCSystem::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this VSSystem::destructor
- }
-
-
- # Use vsFileVSPath and prepend view information.
- #
- method CCSystem::vsFileUserPath {this name type} {
- set vobPath [$this vsFileVSPath $name $type]
- return [CCSystem::viewPath $vobPath]
- }
-
-
- # Get system path through vsObjectVSPath and append file name.
- #
- method CCSystem::vsFileVSPath {this name type} {
- set systemPath [CCSystem::vsObjectVSPath $this]
- set filePath [path_name concat $systemPath [$this getFileName $name $type]]
- return $filePath
- }
-
- proc CCSystem::createVSPath {path} {
- VSSystem::createVSPath CCSystem $path
- }
-
- proc CCSystem::createUserPath {path} {
- VSSystem::createUserPath CCSystem $path
- }
-
-
- # Use vsObjectVSPath and prepend view information to
- # make view-extended pathname.
- #
- proc CCSystem::vsObjectUserPath {object} {
- set vobPath [CCSystem::vsObjectVSPath $object]
- return [CCSystem::viewPath $vobPath]
- }
-
-
- # Default implementation: return path
- # of Object using the builtin path method.
- #
- proc CCSystem::vsObjectVSPath {object} {
- # this is ugly, but necessary
- if [$object isA SystemVersion] {
- set vobPath [$object SystemVersion::path]
- } elseif [$object isA ConfigVersion] {
- # sport7 only
- set vobPath [$object ConfigVersion::path]
- } else {
- set vobPath [$object path]
- }
- return $vobPath
- }
-
-
- # Return user path of this system using
- # vsObjectUserPath.
- #
- method CCSystem::vsUserPath {this} {
- return [CCSystem::vsObjectUserPath $this]
- }
-
-
- # Return vcm path of this system using
- # vsObjectVSPath.
- #
- method CCSystem::vsVsPath {this} {
- return [CCSystem::vsObjectVSPath $this]
- }
-
-
- # Returns a list of ClearCase files found
- # in the directories specified by pathList.
- #
- method CCSystem::fileList {this pathList} {
- return [CCCommand::shortListing $pathList]
- }
-
- proc CCSystem::renameVSDirectory {oldPath newPath} {
- set dir [path_name directory $oldPath]
-
- # check out directory if necessary
- if { ![CCSystem::checkOutDirectory $dir \
- "Checked out by ObjectTeam for directory rename"] } {
- return 0
- }
-
- set renameCommand [CCCommand::rename $oldPath $newPath]
- return [vsCommandHandler execute $renameCommand]
- }
-
-
- # Make a view path of the indicated vobPath.
- #
- proc CCSystem::viewPath {vobPath} {
- set view [m4_var get M4_ccase_view]
-
- if { $view == "" } {
- return $vobPath
- }
-
- if $win95 {
- set viewPath [path_name concat M: $view]
- } else {
- set viewPath [path_name concat /view $view]
- }
- return "$viewPath$vobPath"
- }
-
-
- # Do nothing: ClearCase directories are always
- # created in User env.
- #
- proc CCSystem::createVSDirectory {path} {
- }
-
-
- # Create specified directory in current view as
- # ClearCase directory element.
- # All components except the new one must already exist.
- #
- proc CCSystem::createUserDirectory {path} {
- set dir [path_name directory $path]
-
- # check out directory if necessary
- if { ![CCSystem::checkOutDirectory $dir \
- "Checked out by ObjectTeam for directory creation"] } {
- return 0
- }
-
- set comment "Created by ObjectTeam"
- set mkdirCommand [CCCommand::createElem $path directory $comment]
- return [vsCommandHandler execute $mkdirCommand]
- }
-
-
- # Return whether the given user path indicates
- # a ClearCase directory.
- #
- proc CCSystem::directoryExists {path} {
- if { ![file isdirectory $path] } {
- return 0
- }
-
- return [CCCommand::existsInVob $path]
- }
-
-
- # If the specified directory is not checked out try to get
- # a reserved checkout with the specified comment.
- # Returns 1 on success, 0 on failure.
- #
- #
- proc CCSystem::checkOutDirectory {directory comment} {
- if { ![CCCommand::isCheckedOut $directory] } {
- set checkoutCommand [CCCommand::checkOut $directory $comment 1]
- return [vsCommandHandler execute $checkoutCommand]
- }
- return 1
- }
-
-
- # Returns whether the file with the given name and type exists in the VCM
- # environment.
- #
- method CCSystem::fileExists {this name type} {
- set filePath [$this vsFileUserPath $name $type]
- return [file exists $filePath]
- }
-
-
- # Move specified file to this system and return
- # resulting object on success.
- #
- method CCSystem::move {this vsFile} {
- # move if source system is ClearCase
- if [[$vsFile systemVersion] isA CCSystem] {
- set destDir [$this path]
- # create directory if necessary
- if { ![file isdirectory $destDir] } {
- if { ![CCSystem::createUserPath $destDir] } {
- return 0
- }
- }
-
- # check out destination directory if necessary
- if { ![CCSystem::checkOutDirectory $destDir \
- "Checked out by ObjectTeam for file move"] } {
- return 0
- }
-
- # check out source directory if necessary
- set srcDir [path_name directory [$vsFile path]]
- if { ![CCSystem::checkOutDirectory $srcDir \
- "Checked out by ObjectTeam for file move"] } {
- return 0
- }
- set renameCommand [CCCommand::rename [$vsFile path] $destDir]
- return [vsCommandHandler execute $renameCommand]
- }
-
- # source is not clearcase: copy and delete
- if { [$this VSSystem::copy $vsFile] != "" } {
- return [$vsFile removeFromVS]
- }
-
- return 0
- }
-
- # Do not delete this line -- regeneration end marker
-
-