use Carp;
-use lib '../..';
-
-use Clearcase;
-use Clearcase::Element;
-use Clearcase::UCM::Activity;
-
-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, $baseline, $pvob) = @_;
=pod
=cut
- my $self = bless {
+ $class = bless {
name => $baseline,
- pvob => Clearcase::vobtag $pvob,
+ pvob => $pvob,
}, $class; # bless
-
- return $self;
+
+ return $class;
} # new
-sub name () {
+sub name() {
my ($self) = @_;
-
+
=pod
=head2 name
return $self->{name};
} # name
-sub pvob () {
+sub pvob() {
my ($self) = @_;
-
+
=pod
=head2 pvob
return $self->{pvob};
} # pvob
-
-sub create ($$;$$) {
- my ($self, $project, $pvob, $baseline, $opts) = @_;
+
+sub create($;$$$) {
+ my ($self, $view, $comment, $opts) = @_;
=pod
=head2 create
-Creates a new UCM Stream Object
+Creates a new UCM Baseline Object
Parameters:
=over
-=item UCM Project (required)
-
-UCM Project this stream belongs to
-
-=item PVOB (Required)
-
-Project Vob
-
-=item baseline
-
-Baseline to set this stream to
-
=item opts
-Options: Additional options to use (e.g. -readonly)
+Options: Additional options to use
=back
=cut
- # Fill in object members
- $self->{project} = $project;
- $self->{pvob} = $pvob;
-
- # Fill in opts
$opts ||= '';
- $opts .= " -baseline $baseline"
- if $baseline;
-
- $self->{readonly} = $opts =~ /-readonly/;
-
- # TODO: This should call the exists function
- # Return the stream name if the stream already exists
- my ($status, @output) =
- $Clearcase::CC->execute ('lsstream -short ' . $self->{name});
-
- return ($status, @output)
- unless $status;
-
- # Need to create the stream
- return $Clearcase::CC->execute
- ("mkstream $opts -in " . $self->{project} .
- "\@" . $self->{pvob} .
- ' ' . $self->{name});
+
+ $comment = Clearcase::_setComment $comment;
+
+ return $Clearcase::CC->execute(
+ "mkbl $comment $opts -view " . $view->tag . ' ' . $self->{name}
+ );
} # create
-sub remove (\%) {
- my ($self, %opts) = @_;
+sub remove($) {
+ my ($self, $opts) = @_;
=pod
=cut
- my $opts = $self->_processOpts (%opts);
-
- my $pvob = Clearcase::vobtag ($self->{pvob});
-
- my ($status, @output) = $Clearcase::CC->execute
- ("rmbl $opts " . $self->{name} . '@' . $pvob);
-
- return;
+ $opts ||= '';
+
+ return $Clearcase::CC->execute(
+ "rmbl $opts -force " . $self->{name} . '@' . $self->{pvob}->name
+ );
} # remove
sub attributes () {
=cut
- return $self->Clearcase::attributes (
+ return $self->Clearcase::attributes(
'baseline',
- "$self->{name}\@" . Clearcase::vobtag ($self->{pvob})
+ "$self->{name}\@" . $self->{pvob}->name
);
} # attributes
-sub diff ($;$$) {
+sub diff($;$$) {
my ($self, $type, $baseline, %opts) = @_;
-
+
=pod
=head2 diff
croak "Type must be one of activities, versions or baselines in "
. "Clearcase::UCM::Baseline::diff - not $type";
} # unless
-
+
my $myBaseline = "$self->{name}\@$self->{pvob}";
-
+
my $cmd = "diffbl -$type";
-
+
if ($baseline) {
if ($baseline =~ /(\S+):/) {
unless ($1 eq 'baseline' or $1 eq 'stream') {
. "just <baseline>";
} # unless
} # if
-
+
$baseline .= "\@$self->{pvob}" unless $baseline =~ /\@/;
-
+
$cmd .= " $myBaseline $baseline";
} else {
$cmd .= " -predeccsor";
} # if
-
- $Clearcase::CC->execute ($cmd);
-
+
+ $Clearcase::CC->execute($cmd);
+
return if $Clearcase::CC->status;
-
+
my @output = $Clearcase::CC->output;
my %info;
-
- foreach (@output) {
+
+ for (@output) {
next unless /^(\>\>|\<\<)/;
-
+
if (/(\>\>|\<\<)\s+(\S+)\@/) {
- $info{$2} = Clearcase::UCM::Activity->new ($2, $self->{pvob});
+ $info{$2} = Clearcase::UCM::Activity->new($2, $self->{pvob});
} # if
- } # foreach
-
+ } # for
+
return %info;
} # diff