my @changeset = $activity->changeset;
- foreach my $element (@changeset) {
+ for my $element (@changeset) {
display "Element name: " . $element->pname;
display "Element verison: " . $element->version;
- } # foreach
+ } # for
=head1 DESCRIPTION
use strict;
use warnings;
-use lib '../..';
-
-use Clearcase;
-use Clearcase::Element;
-
# We should really inherit these from a more generic super class...
-sub _processOpts (%) {
+sub _processOpts(%) {
my ($self, %opts) = @_;
my $opts;
- foreach (keys %opts) {
+ for (keys %opts) {
if ($_ eq 'cq' or $_ eq 'cqe' or $_ eq 'force' or $_ eq 'nc') {
$opts .= "-$_ ";
} elsif ($_ eq 'c' or $_ eq 'cfile') {
$opts .= "-$_ $opts{$_}";
} # if
- } # foreach
+ } # for
return $opts;
} # _processOpts
-sub new ($$) {
+sub new($$) {
my ($class, $activity, $pvob) = @_;
=pod
=cut
- my $self = bless {
+ $class = bless {
name => $activity,
- pvob => Clearcase::vobtag ($pvob),
+ pvob => $pvob,
type => $activity =~ /^(deliver|rebase)./ ? 'integration' : 'regular',
}, $class; # bless
- return $self;
+ return $class;
} # new
-sub name () {
+sub name() {
my ($self) = @_;
=pod
return $self->{name};
} # name
-sub pvob () {
+sub pvob() {
my ($self) = @_;
=pod
return $self->{pvob};
} # pvob
-sub type () {
+sub type() {
my ($self) = @_;
=pod
return $self->{type};
} # type
-sub contrib_acts () {
+sub contrib_acts() {
my ($self) = @_;
=pod
=cut
- $self->updateActivityInfo () unless $self->{contrib_acts};
+ $self->updateActivityInfo() unless $self->{contrib_acts};
return $self->{contrib_acts};
} # crm_record
-sub crm_record_id () {
+sub crm_record_id() {
my ($self) = @_;
=pod
=cut
- $self->updateActivityInfo () unless $self->{crm_record_id};
+ $self->updateActivityInfo() unless $self->{crm_record_id};
return $self->{crm_record_id};
} # crm_record_id
-sub crm_record_type () {
+sub crm_record_type() {
my ($self) = @_;
=pod
=cut
- $self->updateActivityInfo () unless $self->{crm_record_type};
+ $self->updateActivityInfo() unless $self->{crm_record_type};
return $self->{crm_record_type};
} # crm_record_type
-sub crm_state () {
+sub crm_state() {
my ($self) = @_;
=pod
=cut
- $self->updateActivityInfo () unless $self->{crm_state};
+ $self->updateActivityInfo() unless $self->{crm_state};
return $self->{crm_state};
} # crm_state
-sub headline () {
+sub headline() {
my ($self) = @_;
=pod
=cut
- $self->updateActivityInfo () unless $self->{headline};
+ $self->updateActivityInfo() unless $self->{headline};
return $self->{headline};
} # headline
-sub name_resolver_view () {
+sub name_resolver_view() {
my ($self) = @_;
=pod
=cut
- $self->updateActivityInfo () unless $self->{name_resolver_view};
+ $self->updateActivityInfo() unless $self->{name_resolver_view};
return $self->{name_resolver_view};
} # name_resolver_view
-sub stream () {
+sub stream() {
my ($self) = @_;
=pod
=cut
- $self->updateActivityInfo () unless $self->{stream};
+ $self->updateActivityInfo() unless $self->{stream};
return $self->{stream};
} # stream
-sub changeset (;$) {
+sub changeset(;$) {
my ($self, $recalc) = @_;
=pod
my $cmd = "lsact -fmt \"%[versions]CQp\" $self->{name}\@$pvob";
- my ($status, @output) = $Clearcase::CC->execute ($cmd);
+ my ($status, @output) = $Clearcase::CC->execute($cmd);
return ($status, @output)
if $status;
@output = split /\", \"/, $output[0]
if $output[0];
- foreach (@output) {
+ for (@output) {
# Skip any cleartool warnings. We are getting warnings of the form:
# "A version in the change set of activity "63332.4" is currently
# unavailable". Probably some sort of subtle corruption that we can ignore.
# Additionally we will set into the $element object the extended name. This
# is the long pathname that we need to use from our current context to be
# able to access the element.
- #$element->setExtendedName ($_);
+ #$element->setExtendedName($_);
push @changeset, $element;
- } # foreach
+ } # for
$self->{changeset} = \@changeset;
return @changeset;
} # changeset
-sub create ($$$;$) {
- my ($self, $stream, $pvob, $headline, $opts) = @_;
+sub exists() {
+ my ($self) = @_;
+
+ my ($status, @output) = $Clearcase::CC->execute(
+ 'lsactivity ' . $self->{name} . '@' . $self->pvob->tag
+ );
+
+ return !$status;
+} # exists
+
+sub create($$$;$) {
+ my ($self, $stream, $headline, $opts) = @_;
=pod
=over
-=item UCM Stream (required)
+=item UCM Stream(required)
UCM stream this activities is to be created on
=cut
- # Fill in members
- $self->{stream} = $stream;
- $self->{pvob} = $pvob;
-
- # TODO: Should quote $headline to protect from special characters
- $self->{headline} = $headline;
-
+ if ($self->exists) {
+ $self->updateActivityInfo;
+
+ return (0, ());
+ } # if
+
# Fill in opts
$opts ||= '';
- $opts .= " -headline '$headline'"
- if $headline;
+
+ if ($headline) {
+ $self->{headline} = $headline;
+
+ $opts .= " -headline '$headline'";
+ } # if
- # TODO: This should call the exists function
- # Return the stream name if the stream already exists
- my ($status, @output) =
- $Clearcase::CC->execute ('lsact -short ' . $self->{name});
+ $self->{stream} = Clearcase::UCM::Stream->new($stream, $self->{pvob});
- return ($status, @output)
- unless $status;
-
- # Need to create the stream
return $Clearcase::CC->execute
- ("mkactivity $opts -in " . $stream .
- "\@" . $pvob .
- ' ' . $self->{name});
+ ("mkactivity $opts -in " . $stream->{name} .
+ '@' . $self->pvob->{tag} .
+ ' ' . $self->{name} .
+ '@' . $self->pvob->{tag});
} # create
-sub remove () {
+sub remove() {
my ($self) = @_;
=pod
=cut
return $Clearcase::CC->execute
- ('rmactivity -f ' . $self->{name} . "\@" . $self->{pvob});
+ ('rmactivity -f ' . $self->{name} . "\@" . $self->{pvob}->name);
} # remove
-sub attributes (;%) {
+sub attributes(;%) {
my ($self, %newAttribs) = @_;
=pod
=cut
- return $self->Clearcase::attributes (
+ return $self->Clearcase::attributes(
'activity',
- "$self->{name}\@" . Clearcase::vobtag ($self->{pvob}),
+ "$self->{name}\@" . $self->{pvob}->name,
%newAttribs,
);
} # attributes
-sub updateActivityInfo () {
+sub updateActivityInfo() {
my ($self) = @_;
# Get all information that can be gotten using -fmt
$fmt = '%[contrib_acts]CXp==';
} # if
- $Clearcase::CC->execute (
- "lsactivity -fmt \"$fmt\" $self->{name}@" . Clearcase::vobtag ($self->{pvob})
+ $Clearcase::CC->execute(
+ "lsactivity -fmt \"$fmt\" $self->{name}@" . $self->{pvob}->name
);
# Assuming this activity is an empty shell of an object that the user may
$self->{contrib_acts} = ();
if ($self->type eq 'integration') {
- foreach (split ', ', $fields[7]) {
- push @{$self->{contrib_acts}}, Clearcase::UCM::Activity->new ($_);
- } # foreach
+ for (split ', ', $fields[7]) {
+ push @{$self->{contrib_acts}}, Clearcase::UCM::Activity->new($_);
+ } # for
} # if
return;
=head2 ClearSCM Perl Modules
-=for html <p><a href="/php/cvs_man.php?file=lib/Clearcase.pm">Clearcase</a></p>
+=for html <p><a href="/php/scm_man.php?file=lib/Clearcase.pm">Clearcase</a></p>
=head1 INCOMPATABILITIES