home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
contsystem.tcl
< prev
next >
Wrap
Text File
|
1997-11-20
|
8KB
|
284 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)contsystem.tcl /main/titanic/11
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)contsystem.tcl /main/titanic/11 20 Nov 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
method getVsType
}
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} {
# cannot create a VCM path directly in continuus, only through
# some version of a project
return 1
}
proc ContSystem::createUserPath {path} {
VSSystem::createUserPath ContSystem $path
}
# Get a continuus file object with given paths.
#
proc ContSystem::getFileObject {userPath vsPath} {
set contFile [VSSystem::getFileObject $userPath $vsPath]
ContFile promote $contFile
set system [$contFile systemVersion]
ContSystem promote $system
$contFile systemVersion $system
return $contFile
}
# 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]
} else {
set objectPath [$object path]
}
global ContCommand::contPathIgnore
set ignore ${ContCommand::contPathIgnore}
if { $ignore != "" } {
set comparePath [eval file join [file split $objectPath]]
if { ![string match "$ignore*" $comparePath] } {
VSSystem::warnForAbsolutePath
set ignore ""
return [eval file join [lrange [file split $objectPath] 1 end]]
}
}
if { $ignore == "" } {
# strip homedir in default situation
set homeDir [M4Login::getHomeDir]
set projectPathIndex [expr [string length $homeDir] +1]
set projectPath [string range $objectPath $projectPathIndex end]
return $projectPath
}
set ignoreLength [string length $ignore]
return [string range $objectPath [expr $ignoreLength + 1] end]
}
# 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} {
return 1
}
# 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
}
# Return Continuus Type of specified file.
#
method ContSystem::getVsType {this path} {
return [ContCommand::getContinuusType $path]
}
# Do not delete this line -- regeneration end marker