3 =head1 NAME $RCSfile: Baseline.pm,v $
5 Object oriented interface to UCM Streams
13 Andrew DeFaria <Andrew@ClearSCM.com>
21 Fri May 14 18:16:16 PDT 2010
25 $Date: 2011/11/15 01:59:07 $
31 Provides access to information about Clearcase Elements.
33 my $stream= new Clearcase::UCM::Stream ($name, $pvob);
37 This module implements a UCM Stream object
41 The following routines are exported:
45 package Clearcase::UCM::Baseline;
55 use Clearcase::Element;
56 use Clearcase::UCM::Activity;
58 sub _processOpts (%) {
59 my ($self, %opts) = @_;
63 foreach (keys %opts) {
64 if ($_ eq 'cq' or $_ eq 'cqe' or $_ eq 'force' or $_ eq 'nc') {
66 } elsif ($_ eq 'c' or $_ eq 'cfile') {
67 $opts .= "-$_ $opts{$_}";
76 my ($class, $baseline, $pvob) = @_;
82 Construct a new Clearcase Stream object.
86 =for html <blockquote>
96 =for html </blockquote>
100 =for html <blockquote>
104 =item Clearcase Stream object
108 =for html </blockquote>
114 pvob => Clearcase::vobtag $pvob,
127 Returns the name of the stream
131 =for html <blockquote>
139 =for html </blockquote>
143 =for html <blockquote>
151 =for html </blockquote>
155 return $self->{name};
165 Returns the pvob of the stream
169 =for html <blockquote>
177 =for html </blockquote>
181 =for html <blockquote>
189 =for html </blockquote>
193 return $self->{pvob};
197 my ($self, $project, $pvob, $baseline, $opts) = @_;
203 Creates a new UCM Stream Object
207 =for html <blockquote>
211 =item UCM Project (required)
213 UCM Project this stream belongs to
215 =item PVOB (Required)
221 Baseline to set this stream to
225 Options: Additional options to use (e.g. -readonly)
229 =for html </blockquote>
233 =for html <blockquote>
239 Status from cleartool
247 =for html </blockquote>
251 # Fill in object members
252 $self->{project} = $project;
253 $self->{pvob} = $pvob;
257 $opts .= " -baseline $baseline"
260 $self->{readonly} = $opts =~ /-readonly/;
262 # TODO: This should call the exists function
263 # Return the stream name if the stream already exists
264 my ($status, @output) =
265 $Clearcase::CC->execute ('lsstream -short ' . $self->{name});
267 return ($status, @output)
270 # Need to create the stream
271 return $Clearcase::CC->execute
272 ("mkstream $opts -in " . $self->{project} .
273 "\@" . $self->{pvob} .
274 ' ' . $self->{name});
278 my ($self, %opts) = @_;
288 =for html <blockquote>
296 Options: Additional options to use (e.g. -c, -force, etc.)
300 =for html </blockquote>
304 =for html <blockquote>
310 Remember to check status method for error, and/or output method for output.
314 =for html </blockquote>
318 my $opts = $self->_processOpts (%opts);
320 my $pvob = Clearcase::vobtag ($self->{pvob});
322 my ($status, @output) = $Clearcase::CC->execute
323 ("rmbl $opts " . $self->{name} . '@' . $pvob);
335 Returns a hash of the attributes associated with a baseline
339 =for html <blockquote>
347 =for html </blockquote>
351 =for html <blockquote>
357 Hash of attributes for this baseline
361 =for html </blockquote>
365 return $self->Clearcase::attributes (
367 "$self->{name}\@" . Clearcase::vobtag ($self->{pvob})
372 my ($self, $type, $baseline, %opts) = @_;
378 Returns a hash of information regarding the difference between two baselines or
379 a baseline and the stream (AKA "top of stream").
383 =for html <blockquote>
387 =item [activities|versions|baselines]
389 Must specify one of [activities|versions|baselines]. Information will be
390 returned based on this parameter.
392 =item $baseline or $stream
394 Specify the baseline or stream to compare to. If not specified a -predeccsor
395 diffbl will be done. If a stream use "stream:<stream>" otherwise use
396 "baseline:<baseline>" or simply "<baseline>".
404 =for html </blockquote>
408 =for html <blockquote>
414 Depending on whether activites, versions or baselines were specified, the
415 returned hash will be constructed with the key being the activity, version
416 string or baseline name as the key with additional information specified as the
421 =for html </blockquote>
425 unless ($type =~ /^activities$/i or
426 $type =~ /^versions$/i or
427 $type =~ /^baselines$/i) {
428 croak "Type must be one of activities, versions or baselines in "
429 . "Clearcase::UCM::Baseline::diff - not $type";
432 my $myBaseline = "$self->{name}\@$self->{pvob}";
434 my $cmd = "diffbl -$type";
437 if ($baseline =~ /(\S+):/) {
438 unless ($1 eq 'baseline' or $1 eq 'stream') {
439 croak "Baseline should be baseline:<baseline> or stream:<stream> or "
444 $baseline .= "\@$self->{pvob}" unless $baseline =~ /\@/;
446 $cmd .= " $myBaseline $baseline";
448 $cmd .= " -predeccsor";
451 $Clearcase::CC->execute ($cmd);
453 return if $Clearcase::CC->status;
455 my @output = $Clearcase::CC->output;
460 next unless /^(\>\>|\<\<)/;
462 if (/(\>\>|\<\<)\s+(\S+)\@/) {
463 $info{$2} = Clearcase::UCM::Activity->new ($2, $self->{pvob});
474 =head2 ClearSCM Perl Modules
476 =for html <p><a href="/php/scm_man.php?file=lib/Clearcase.pm">Clearcase</a></p>
478 =head1 INCOMPATABILITIES
482 =head1 BUGS AND LIMITATIONS
484 There are no known bugs in this module.
486 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
488 =head1 LICENSE AND COPYRIGHT
490 Copyright (c) 2007, ClearSCM, Inc. All rights reserved.