File Coverage

lib/Clearcase/UCM/Baseline.pm
Criterion Covered Total %
statement 9 53 16.9
branch 0 20 0.0
condition 0 25 0.0
subroutine 3 11 27.2
pod 7 7 100.0
total 19 116 16.3


line stmt bran cond sub pod time code
1              
2             =pod
3              
4             =head1 NAME Baseline.pm
5              
6             Object oriented interface to UCM Streams
7              
8             =head1 VERSION
9              
10             =over
11              
12             =item Author
13              
14             Andrew DeFaria
15              
16             =item Revision
17              
18             $Revision: 1.4 $
19              
20             =item Created
21              
22             Fri May 14 18:16:16 PDT 2010
23              
24             =item Modified
25              
26             $Date: 2011/11/15 01:59:07 $
27              
28             =back
29              
30             =head1 SYNOPSIS
31              
32             Provides access to information about Clearcase Elements.
33              
34             my $stream= new Clearcase::UCM::Stream ($name, $pvob);
35              
36             =head1 DESCRIPTION
37              
38             This module implements a UCM Stream object
39              
40             =head1 ROUTINES
41              
42             The following routines are exported:
43              
44             =cut
45              
46             package Clearcase::UCM::Baseline;
47              
48 1     1   884 use strict;
  1         2  
  1         28  
49 1     1   3 use warnings;
  1         2  
  1         33  
50              
51 1     1   3 use Carp;
  1         2  
  1         851  
52              
53             sub _processOpts(%) {
54 0     0     my ($self, %opts) = @_;
55              
56 0           my $opts;
57              
58 0           for (keys %opts) {
59 0 0 0       if ($_ eq 'cq' or $_ eq 'cqe' or $_ eq 'force' or $_ eq 'nc') {
    0 0        
      0        
      0        
60 0           $opts .= "-$_ ";
61             } elsif ($_ eq 'c' or $_ eq 'cfile') {
62 0           $opts .= "-$_ $opts{$_}";
63             } # if
64             } # for
65              
66 0           return $opts;
67             } # _processOpts
68              
69             sub new($$) {
70 0     0 1   my ($class, $baseline, $pvob) = @_;
71              
72             =pod
73              
74             =head2 new
75              
76             Construct a new Clearcase Stream object.
77              
78             Parameters:
79              
80             =for html
81              
82             =over
83              
84             =item stream name
85              
86             Name of stream
87              
88             =back
89              
90             =for html
91              
92             Returns:
93              
94             =for html
95              
96             =over
97              
98             =item Clearcase Stream object
99              
100             =back
101              
102             =for html
103              
104             =cut
105              
106 0           $class = bless {
107             name => $baseline,
108             pvob => $pvob,
109             },
110             $class; # bless
111              
112 0           return $class;
113             } # new
114              
115             sub name() {
116 0     0 1   my ($self) = @_;
117              
118             =pod
119              
120             =head2 name
121              
122             Returns the name of the stream
123              
124             Parameters:
125              
126             =for html
127              
128             =over
129              
130             =item none
131              
132             =back
133              
134             =for html
135              
136             Returns:
137              
138             =for html
139              
140             =over
141              
142             =item stream's name
143              
144             =back
145              
146             =for html
147              
148             =cut
149              
150 0           return $self->{name};
151             } # name
152              
153             sub pvob() {
154 0     0 1   my ($self) = @_;
155              
156             =pod
157              
158             =head2 pvob
159              
160             Returns the pvob of the stream
161              
162             Parameters:
163              
164             =for html
165              
166             =over
167              
168             =item none
169              
170             =back
171              
172             =for html
173              
174             Returns:
175              
176             =for html
177              
178             =over
179              
180             =item stream's pvob
181              
182             =back
183              
184             =for html
185              
186             =cut
187              
188 0           return $self->{pvob};
189             } # pvob
190              
191             sub create($;$$$) {
192 0     0 1   my ($self, $view, $comment, $opts) = @_;
193              
194             =pod
195              
196             =head2 create
197              
198             Creates a new UCM Baseline Object
199              
200             Parameters:
201              
202             =for html
203              
204             =over
205              
206             =item opts
207              
208             Options: Additional options to use
209              
210             =back
211              
212             =for html
213              
214             Returns:
215              
216             =for html
217              
218             =over
219              
220             =item $status
221              
222             Status from cleartool
223              
224             =item @output
225              
226             Ouput from cleartool
227              
228             =back
229              
230             =for html
231              
232             =cut
233              
234 0   0       $opts ||= '';
235              
236 0           $comment = Clearcase::setComment $comment;
237              
238             return $Clearcase::CC->execute (
239 0           "mkbl $comment $opts -view " . $view->tag . ' ' . $self->{name});
240             } # create
241              
242             sub remove($) {
243 0     0 1   my ($self, $opts) = @_;
244              
245             =pod
246              
247             =head2 remove
248              
249             Removes UCM Baseline
250              
251             Parameters:
252              
253             =for html
254              
255             =over
256              
257             =item none
258              
259             =item %opts
260              
261             Options: Additional options to use (e.g. -c, -force, etc.)
262              
263             =back
264              
265             =for html
266              
267             Returns:
268              
269             =for html
270              
271             =over
272              
273             =item nothing
274              
275             Remember to check status method for error, and/or output method for output.
276              
277             =back
278              
279             =for html
280              
281             =cut
282              
283 0   0       $opts ||= '';
284              
285             return $Clearcase::CC->execute (
286 0           "rmbl $opts -force " . $self->{name} . '@' . $self->{pvob}->name);
287             } # remove
288              
289             sub attributes () {
290 0     0 1   my ($self) = @_;
291              
292             =pod
293              
294             =head2 attributes
295              
296             Returns a hash of the attributes associated with a baseline
297              
298             Parameters:
299              
300             =for html
301              
302             =over
303              
304             =item none
305              
306             =back
307              
308             =for html
309              
310             Returns:
311              
312             =for html
313              
314             =over
315              
316             =item %attributes
317              
318             Hash of attributes for this baseline
319              
320             =back
321              
322             =for html
323              
324             =cut
325              
326             return $self->Clearcase::attributes ('baseline',
327 0           "$self->{name}\@" . $self->{pvob}->name);
328             } # attributes
329              
330             sub diff($;$$) {
331 0     0 1   my ($self, $type, $baseline, %opts) = @_;
332              
333             =pod
334              
335             =head2 diff
336              
337             Returns a hash of information regarding the difference between two baselines or
338             a baseline and the stream (AKA "top of stream").
339              
340             Parameters:
341              
342             =for html
343              
344             =over
345              
346             =item [activities|versions|baselines]
347              
348             Must specify one of [activities|versions|baselines]. Information will be
349             returned based on this parameter.
350              
351             =item $baseline or $stream
352              
353             Specify the baseline or stream to compare to. If not specified a -predeccsor
354             diffbl will be done. If a stream use "stream:" otherwise use
355             "baseline:" or simply "".
356              
357             =item %opts
358              
359             Additional options.
360              
361             =back
362              
363             =for html
364              
365             Returns:
366              
367             =for html
368              
369             =over
370              
371             =item %info
372              
373             Depending on whether activites, versions or baselines were specified, the
374             returned hash will be constructed with the key being the activity, version
375             string or baseline name as the key with additional information specified as the
376             value.
377              
378             =back
379              
380             =for html
381              
382             =cut
383              
384 0 0 0       unless ($type =~ /^activities$/i
      0        
385             or $type =~ /^versions$/i
386             or $type =~ /^baselines$/i)
387             {
388 0           croak "Type must be one of activities, versions or baselines in "
389             . "Clearcase::UCM::Baseline::diff - not $type";
390             } # unless
391              
392 0           my $myBaseline = "$self->{name}\@$self->{pvob}";
393              
394 0           my $cmd = "diffbl -$type";
395              
396 0 0         if ($baseline) {
397 0 0         if ($baseline =~ /(\S+):/) {
398 0 0 0       unless ($1 eq 'baseline' or $1 eq 'stream') {
399 0           croak "Baseline should be baseline: or stream: or "
400             . "just ";
401             } # unless
402             } # if
403              
404 0 0         $baseline .= "\@$self->{pvob}" unless $baseline =~ /\@/;
405              
406 0           $cmd .= " $myBaseline $baseline";
407             } else {
408 0           $cmd .= " -predeccsor";
409             } # if
410              
411 0           $Clearcase::CC->execute ($cmd);
412              
413 0 0         return if $Clearcase::CC->status;
414              
415 0           my @output = $Clearcase::CC->output;
416              
417 0           my %info;
418              
419 0           for (@output) {
420 0 0         next unless /^(\>\>|\<\<)/;
421              
422 0 0         if (/(\>\>|\<\<)\s+(\S+)\@/) {
423 0           $info{$2} = Clearcase::UCM::Activity->new ($2, $self->{pvob});
424             } # if
425             } # for
426              
427 0           return %info;
428             } # diff
429              
430             1;
431              
432             =head1 DEPENDENCIES
433              
434             =head2 Modules
435              
436             =over
437              
438             =item L
439              
440             =back
441              
442             =head1 INCOMPATABILITIES
443              
444             None
445              
446             =head1 BUGS AND LIMITATIONS
447              
448             There are no known bugs in this module.
449              
450             Please report problems to Andrew DeFaria .
451              
452             =head1 COPYRIGHT AND LICENSE
453              
454             Copyright (C) 2020 by Andrew@DeFaria.com
455              
456             This library is free software; you can redistribute it and/or modify
457             it under the same terms as Perl itself, either Perl version 5.38.0 or,
458             at your option, any later version of Perl 5 you may have available.
459              
460             =cut