Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic SYNERGY (steve huntington)
Decrease font size
Increase font size
Topic Title: Update Project History
Topic Summary: Script updates project history of working state project to match reconfigure properties baseline project
Created On: 13-Oct-2006 20:40
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 13-Oct-2006 20:40
User is offline View Users Profile Print this message


Todd Alden

Posts: 71
Joined: 4-Oct-2002

#!/usr/std/bin/perl5.6.1

# This script will re-evaluate the history links of your projects and then
# set them according to the "baseline" value. The history info will be
# not be changed if the baseline information is not appropriate.
#
# the script takes any number of arguments:
# databases to operate on
#
# 01 SEP 2006: Modified to only operate on working state project (since
# prep state project history is preserved when doing "Create
# Baseline". (script used to operate on both working and prep
# state projects)
# Todd Alden
#

# Make perl handle print buffer flushing
$| = 1;

# Set your environment variables here
$ENV{CCM_HOME}="/vol/ccm64";


foreach $database (@ARGV)
{

$ENV{CCM_ADDR} = `$ENV{CCM_HOME}/bin/ccm start -d $database -m -q -nogui -r ccm_admin`;

@ccm_status = `$ENV{CCM_HOME}/bin/ccm status`;

$in_session = grep /\(current session\)/, @ccm_status;

# If the user isn't in a CCM session, print an error and die
if(! $in_session)
{
die "$0: CM Synergy session not started\n";
}

# Find all working projects which have a baseline
@projects = `$ENV{CCM_HOME}/bin/ccm query "status='working' and has_baseline_project(cvtype='project')" -u -f %objectname`;
chomp @projects;

foreach $project (@projects)
{
print " project name before clean up: $project \n";
# Clean up the project name
$project =~ s/\s*$//;
print " project name after clean up: $project \n";

# Find the baseline
$relate_data = `$ENV{CCM_HOME}/bin/ccm relate -s -n baseline_project -f "$project" -fmt "%objectname::~%objectname~"`;
print " relate_data: $relate_data \n";
($trash, $baseline) = split /~/, $relate_data;
chomp $baseline;
print " baseline after chomp: $baseline \n";

# Does the baseline project exist?
undef $exist;
$exist = `$ENV{CCM_HOME}/bin/ccm attr -s name "$baseline"`;
if($exist)
{
# Is the baseline different than itself?
if($project ne $baseline)
{
# OK check it's predecessor and update it from the baseline if needed

@predecessors = `$ENV{CCM_HOME}/bin/ccm relate -s -n successor -t "$project"`;
print " predecessor_0: $predecessors[0] \n";
$predecessors[0] =~ s/ successor.*$//;
$predecessors[0] =~ s/ //g;
chomp $predecessors[0];
print " predecessor_0: $predecessors[0] \n";

if($predecessors[0] ne $baseline)
{
undef $exist;
$exist = `$ENV{CCM_HOME}/bin/ccm attr -s name "$predecessors[0]"`;

# Make sure the predecessor exists before doing the unrelate
if($exist)
{
system("$ENV{CCM_HOME}/bin/ccm unrelate -name successor -f '$predecessors[0]' -t '$project'");
}
system("$ENV{CCM_HOME}/bin/ccm relate -name successor -f '$baseline' -t '$project'");
}
else
{
print "Project $project baseline is already the predecessor.\n"
}
}
else
{
print "Project $project has itself as the baseline.\n"
}
}
else
{
print "Project $project has a non-existent or invalid baseline.\n"
}
}

system("$ENV{CCM_HOME}/bin/ccm stop");

}

##### End of script ######


Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic SYNERGY forum.
There are currently 2 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 15:34.
There are currently 0 guests browsing this forum, which makes a total of 2 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.