home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
mtversion.tcl
< prev
next >
Wrap
Text File
|
1997-11-26
|
10KB
|
422 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)mtversion.tcl /main/titanic/19
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)mtversion.tcl /main/titanic/19 26 Nov 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
# End user added include file section
require "mergeobjec.tcl"
Class MTVersion : {MergeObject} {
constructor
method destructor
method hasConflict
method initializeInfo
method getInfo
method merge
method import
method select
method getBaseVersion
method createConflictingObjects
method overwrite
method getOwners
method findToObject
method getVersionableClass
method setVersionableClass
method removeVersionableClass
attribute selectFlag
attribute level
attribute toChanged
attribute fromIsDerived
attribute toIsDerived
attribute copyCommand
attribute versionableClass
}
constructor MTVersion {class this name fromRepObj toRepObj} {
set this [MergeObject::constructor $class $this $name $fromRepObj $toRepObj]
$this toChanged 0
$this fromIsDerived 0
$this toIsDerived 0
$this versionableClass [Dictionary new]
# Start constructor user section
# valid for every version
$this setVersionableClass customFileVersions MTCustFile
$this baseRepObj [$this getBaseVersion]
if {$toRepObj != "" && $toRepObj != $fromRepObj} {
# check if 'fromRepObj' is derived from 'toRepObj'
for {set v $fromRepObj} {!["$v" isNil]} \
{set v [$v baseVersion]} {
if {$v == $toRepObj} {
$this fromIsDerived 1
}
}
# check if 'toRepObj' is derived from 'fromRepObj'
for {set v $toRepObj} {!["$v" isNil]} \
{set v [$v baseVersion]} {
if {$v == $fromRepObj} {
$this toIsDerived 1
}
}
}
# End constructor user section
return $this
}
method MTVersion::destructor {this} {
# Start destructor user section
# End destructor user section
$this MergeObject::destructor
}
method MTVersion::hasConflict {this} {
set to [$this toRepObj]
set fr [$this fromRepObj]
# check if 'to' element does not exist
if {$to == ""} {
return 0
}
if [[$this fromRepObj] isA CustomLevelVersion] {
if [[$this childSet] empty] {
# no children, even if the versions are conflicting
# the version can be merged
return 0
}
}
if [[$this fromRepObj] isA CustomLevelVersion] {
set conflict 0
[$this childSet] foreach child {
if [$child hasConflict] {
set conflict 1
}
}
if {$conflict == 0} {
# no conflicting children, even if the versions
# are conflicting the version can be merged
return 0
}
}
# when importing versions there's always a conflict
# because it can not determined whether it is different or not.
# because the objects are from different object trees
# (mergelinked elements are not shown at all)
if [.main import] {
return 1
}
if {[$this fromIsDerived] || [$this toIsDerived]} {
return 0
}
# now it's clear there's a conflict
return 1
}
method MTVersion::initializeInfo {this} {
set fromVersion [$this fromRepObj]
BrowserProcs::initializeInfo $fromVersion $fromVersion
}
method MTVersion::getInfo {this} {
set owners [$this getOwners]
set fromOwners [lindex $owners 0]
set toOwners [lindex $owners 1]
set info ""
set configs ""
foreach owner $fromOwners {
if {$configs != ""} {
append configs "\n"
}
append configs "- [$owner status] [$owner text]"
}
if {$configs != ""} {
lappend info "From Selected In"
lappend info $configs
}
set configs ""
foreach owner $toOwners {
if {$configs != ""} {
append configs "\n"
}
append configs "- [$owner status] [$owner text]"
}
if {$configs != ""} {
lappend info "To Selected In"
lappend info $configs
}
return $info
}
method MTVersion::merge {this} {
set name [[$this fromRepObj] getInfo Name]
set type [[$this fromRepObj] getInfo Type]
wmtkmessage "Merging object $name.$type"
set success 1
set warning "Cannot merge object, "
set warning "$warning parent object does not exist in 'to' version."
# if no conflict AND there's added in the 'to' version
if {![$this hasConflict] && ![$this toChanged]} {
if ![[$this parent] hasConflict] {
if {[[$this parent] toRepObj] == ""} {
wmtkwarning $warning
return 0
}
}
if {[$this isA MTContainer] && ![$this fromIsDerived] &&
[$this toRepObj] != ""} {
set comment [.main mergeLinkComment]
} else {
$this select
return 1
}
}
# merge all the children, skip the conflicting ones
# if no children left, create a merge link
if {![$this isA MTContainer]} {
# only merge links if container
# a file is not a container
set success 0
} else {
[$this childSet] foreach child {
if ![$child merge] {
set success 0
}
}
}
if {$success == 1} {
# only merge link if different versions
if {[$this toRepObj] != [$this fromRepObj]} {
set comment [.main mergeLinkComment]
MTProcs::createMergeLink $this $comment
}
}
wmtkmessage ""
return $success
}
method MTVersion::import {this} {
set name [[$this fromRepObj] getInfo Name]
set type [[$this fromRepObj] getInfo Type]
wmtkmessage "Merging object $name.$type"
# import the file
if {[$this toRepObj] != ""} {
MTProcs::makeToWorking $this
} else {
if {[$this parent] != "" && [[$this parent] toRepObj] != ""} {
MTProcs::makeToWorking [$this parent]
} else {
set warning "Cannot merge object, parent object does"
set warning "$warning not exist in 'to' version."
wmtkwarning $warning
wmtkmessage ""
return 0
}
}
set toSys [[$this parent] toRepObj]
set fromObj [$this fromRepObj]
set fromConfig [.main fromConfig]
set copyCmd [$this copyCommand]
if [$fromObj isA GroupVersion] {
set fromSys [[$this parent] fromRepObj]
set toConfig [.main toConfig]
set groupName [$fromObj name]
set cmd "$toSys $copyCmd $fromObj $fromSys $fromConfig \
$toConfig definition"
eval $cmd
# search for the copied GropVersion
set to [$toSys findGroupVersion $groupName]
} elseif [$fromObj isA CustomFileVersion] {
set cmd "$toSys $copyCmd $fromObj"
set to [eval $cmd]
} else {
set cmd "$toSys $copyCmd $fromObj $fromConfig"
set to [eval $cmd]
}
$this toRepObj $to
# create mergelink
MTProcs::createMergeLink $this [.main mergeLinkComment]
wmtkmessage ""
return 1
}
method MTVersion::select {this} {
MTProcs::freeze [$this fromRepObj] [.main freezeComment]
set parentObj [[$this parent] toRepObj]
set selectFlag [$this selectFlag]
set parentObj [MTProcs::makeToWorking [$this parent]]
if {$parentObj == ""} {
return 0
}
if [[$this fromRepObj] isA CustomFileVersion] {
$parentObj select [$this fromRepObj]
} else {
$parentObj select -$selectFlag [$this fromRepObj] \
[[$this fromRepObj] linkStatus]
}
# update rep information
$this toRepObj [$this fromRepObj]
return 1
}
method MTVersion::getBaseVersion {this} {
if {[$this toRepObj] == ""} {
return ""
}
set base [[$this fromRepObj] commonBaseVersion [$this toRepObj]]
if [$base isNil] {
return ""
}
return $base
}
method MTVersion::createConflictingObjects {this} {
global classCount
foreach assoc [$this associations] {
set fromVersions [[$this fromRepObj] $assoc]
if {[$this toRepObj] != ""} {
set toVersions [[$this toRepObj] $assoc]
} else {
set toVersions ""
}
foreach fromVersion $fromVersions {
if [.main import] {
set toVersion [MTProcs::needImport \
$fromVersion $this]
} else {
set toVersion [MTProcs::needMerge \
$fromVersion $toVersions]
}
if {$toVersion == "ok"} {
continue
}
incr classCount
set obj MTVersion$classCount
set class [$this getVersionableClass $assoc]
if {$class == ""} {
# no class, it is not a versionable
continue
}
$class new $obj $fromVersion $toVersion
$this addChild $obj
$fromVersion parent [$this fromRepObj]
if [isCommand $toVersion] {
$toVersion parent [$this toRepObj]
}
}
# now check if the 'to' version is changed (added to)
foreach toVersion $toVersions {
if ![isCommand [MTProcs::findToObject $toVersion \
$fromVersions]] {
# stuff is added
$this toChanged 1
}
}
}
if {[$this toRepObj] == ""} {
return
}
set diffsList [[$this toRepObj] propertyDiffs [$this fromRepObj] \
[$this baseRepObj]]
foreach diffs $diffsList {
set from ""
if ![[lindex $diffs 0] isNil] {
set from [lindex $diffs 0]
MTPropRepObj promote $from
$from setInfo PropertyName [$from name]
$from setInfo Name [[$this fromRepObj] getInfo Name]
$from setInfo Type [[$this fromRepObj] getInfo Type]
}
set to [lindex $diffs 1]
if [$to isNil] {
set to ""
}
if {$to != ""} {
MTPropRepObj promote $to
$to setInfo PropertyName [$to name]
$to setInfo Name [[$this toRepObj] getInfo Name]
$to setInfo Type [[$this toRepObj] getInfo Type]
}
incr classCount
set obj MTVersion$classCount
MTProperty new $obj $from $to
$this addChild $obj
}
}
method MTVersion::overwrite {this} {
return [$this select]
}
method MTVersion::getOwners {this} {
return {{} {}}
}
method MTVersion::findToObject {this} {
return ""
}
# Do not delete this line -- regeneration end marker
method MTVersion::getVersionableClass {this association} {
return [[$this versionableClass] set $association]
}
method MTVersion::setVersionableClass {this association newVersionableClass} {
[$this versionableClass] set $association $newVersionableClass
}
method MTVersion::removeVersionableClass {this association} {
[$this versionableClass] unset $association
}