home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
contsystem.tcl
< prev
next >
Wrap
Text File
|
1997-06-06
|
7KB
|
247 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)contsystem.tcl /main/hindenburg/8
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)contsystem.tcl /main/hindenburg/8 6 Jun 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
# End user added include file section
require_module_file "vssystem.tcl" vcm
# This class represents a Continuus aware system.
Class ContSystem : {VSSystem} {
constructor
method destructor
method vsFileUserPath
method vsFileVSPath
method vsUserPath
method vsVsPath
method fileList
method currentProjectVersion
method fileExists
method move
}
constructor ContSystem {class this name} {
set this [VSSystem::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method ContSystem::destructor {this} {
# Start destructor user section
# End destructor user section
$this VSSystem::destructor
}
# Use vsObjectUserPath to get path name to file.
#
method ContSystem::vsFileUserPath {this name type} {
# path method is redefined in VSSystem to use vsObjectUserPath
set systemPath [$this path]
set filePath [path_name concat $systemPath [$this getFileName $name $type]]
return $filePath
}
# Use vsObjectVSPath to make a relative path name starting with project.
#
method ContSystem::vsFileVSPath {this name type} {
set systemPath [ContSystem::vsObjectVSPath $this]
set filePath [path_name concat $systemPath [$this getFileName $name $type]]
return $filePath
}
proc ContSystem::createVSPath {path} {
VSSystem::createVSPath ContSystem $path
}
proc ContSystem::createUserPath {path} {
VSSystem::createUserPath ContSystem $path
}
# Use default method, strip home directory and make a path to the work area.
#
proc ContSystem::vsObjectUserPath {object} {
set projectPath [ContSystem::vsObjectVSPath $object]
set project [lindex [file_split $projectPath] 0]
set workingVersions [ContCommand::getWorkingProjectVersions $project]
set versionCount [llength $workingVersions]
if { $versionCount == 0 } {
vsCommandHandler error "No working versions of Project $project found"
return ${ContCommand::ccmWorkArea}
}
# if M4_cont_projects is set use the indicated version if it is a
# working one
set version ""
set selectedVersions [m4_var get M4_cont_projects]
if { $selectedVersions != "" } {
foreach projectVersion $selectedVersions {
regexp {(.*)-([^-]*)$} $projectVersion \
dummy selectedProject selectedVersion
if { ($selectedProject == $project) && \
([lsearch -exact $workingVersions $selectedVersion] != -1 ) } {
set version $selectedVersion
break
}
}
}
# version selection: use last working version
if { $version == "" } {
set version [lindex $workingVersions [expr $versionCount -1]]
}
set projectVersion "$project\-$version"
global ContCommand::ccmWorkArea
set projectVersionPath [path_name concat\
${ContCommand::ccmWorkArea} $projectVersion]
set fullPath [path_name concat $projectVersionPath $projectPath]
# final sanity check
if { ![file isdirectory $projectVersionPath] } {
vsCommandHandler error "Project version $projectVersion not found in Work Area"
}
return $fullPath
}
# Returns path of object, first component is project.
#
proc ContSystem::vsObjectVSPath {object} {
# get default path
if [$object isA SystemVersion] {
set objectPath [$object SystemVersion::path]
} elseif [$object isA ConfigVersion] {
set objectPath [$object ConfigVersion::path]
} else {
set objectPath [$object path]
}
# strip homedir
set homeDir [M4Login::getHomeDir]
set projectPathIndex [expr [string length $homeDir] +1]
set projectPath [string range $objectPath $projectPathIndex end]
return $projectPath
}
# Return user environment path of this system
# using vsObjectUserPath.
#
method ContSystem::vsUserPath {this} {
return [ContSystem::vsObjectUserPath $this]
}
# Return vcm system path of this system using
# vsObjectVSPath.
#
method ContSystem::vsVsPath {this} {
return [ContSystem::vsObjectVSPath $this]
}
# Returns a list of Continuus controlled files
# int the directories specified by pathList.
#
method ContSystem::fileList {this pathList} {
return [ContCommand::shortListing $pathList]
}
# Extracts the currently selected project version
# from the system user path and returns it.
#
method ContSystem::currentProjectVersion {this} {
set systemPath [$this path]
global ContCommand::ccmWorkArea
set index [expr [string length ${ContCommand::ccmWorkArea}]+1]
set pathParts [file_split [string range $systemPath $index end]]
# now first path component after work area is project version
if { [llength $pathParts] > 0 } {
return [lindex $pathParts 0]
} else {
return "None"
}
}
proc ContSystem::renameVSDirectory {oldPath newPath} {
set renameCommand [ContCommand::rename $oldPath $newPath]
return [vsCommandHandler execute $renameCommand]
}
# Do nothing: Continuus dirs are always
# created through the work area.
#
proc ContSystem::createVSDirectory {path} {
}
# Create the specified path as Continuus directory element.
# All pathname components except the last
# one must already exist.
#
proc ContSystem::createUserDirectory {path} {
set comment "Created by ObjectTeam"
set mkdirCommand [ContCommand::createObject $path dir $comment 0]
return [vsCommandHandler execute $mkdirCommand]
}
# Return whether the given user path is a directory in the Continuus
# environment.
#
proc ContSystem::directoryExists {path} {
return [file isdirectory $path]
}
# Return whether file with given name and type exists in the VCM environment.
#
method ContSystem::fileExists {this name type} {
set filePath [$this vsFileUserPath $name $type]
return [file exists $filePath]
}
# Move file to this system and return
# resulting object on success.
#
method ContSystem::move {this vsFile} {
if [[$vsFile systemVersion] isA ContSystem] {
set destDir [$this path]
# create directory if necessary
if { ![file isdirectory $destDir] } {
if { ![ContSystem::createUserPath $destDir] } {
return 0
}
}
set renameCommand [ContCommand::rename [$vsFile path] [$this path]]
return [vsCommandHandler execute $renameCommand]
}
# source is not continuus: copy and delete
if { [$this VSSystem::copy $vsFile] != "" } {
return [$vsFile removeFromVS]
}
return 0
}
# Do not delete this line -- regeneration end marker