File Coverage

lib/Clearcase/UCM/Stream.pm
Criterion Covered Total %
statement 6 40 15.0
branch 0 4 0.0
condition 0 4 0.0
subroutine 2 12 16.6
pod 9 10 90.0
total 17 70 24.2


line stmt bran cond sub pod time code
1              
2             =pod
3              
4             =head1 NAME Stream.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.8 $
19              
20             =item Created
21              
22             Fri May 14 18:16:16 PDT 2010
23              
24             =item Modified
25              
26             $Date: 2011/11/15 02:00:58 $
27              
28             =back
29              
30             =head1 SYNOPSIS
31              
32             Provides access to information about Clearcase Streams.
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::Stream;
47              
48 1     1   947 use strict;
  1         1  
  1         30  
49 1     1   3 use warnings;
  1         1  
  1         668  
50              
51             sub new ($$) {
52 0     0 1   my ($class, $name, $pvob) = @_;
53              
54             =pod
55              
56             =head2 new
57              
58             Construct a new Clearcase Stream object.
59              
60             Parameters:
61              
62             =for html
63              
64             =over
65              
66             =item name
67              
68             Name of stream
69              
70             =item pvob
71              
72             Associated pvob
73              
74             =back
75              
76             =for html
77              
78             Returns:
79              
80             =for html
81              
82             =over
83              
84             =item Clearcase Stream object
85              
86             =back
87              
88             =for html
89              
90             =cut
91              
92 0           $class = bless {
93             name => $name,
94             pvob => $pvob,
95             },
96             $class; # bless
97              
98 0           return $class;
99             } # new
100              
101             sub name () {
102 0     0 1   my ($self) = @_;
103              
104             =pod
105              
106             =head2 name
107              
108             Returns the name of the stream
109              
110             Parameters:
111              
112             =for html
113              
114             =over
115              
116             =item none
117              
118             =back
119              
120             =for html
121              
122             Returns:
123              
124             =for html
125              
126             =over
127              
128             =item stream's name
129              
130             =back
131              
132             =for html
133              
134             =cut
135              
136 0           return $self->{name};
137             } # name
138              
139             sub pvob () {
140 0     0 1   my ($self) = @_;
141              
142             =pod
143              
144             =head2 pvob
145              
146             Returns the pvob of the stream
147              
148             Parameters:
149              
150             =for html
151              
152             =over
153              
154             =item none
155              
156             =back
157              
158             =for html
159              
160             Returns:
161              
162             =for html
163              
164             =over
165              
166             =item stream's pvob
167              
168             =back
169              
170             =for html
171              
172             =cut
173              
174 0           return $self->{pvob};
175             } # pvob
176              
177             sub create ($;$) {
178 0     0 1   my ($self, $project, $opts) = @_;
179              
180             =pod
181              
182             =head2 create
183              
184             Creates a new UCM Stream Object
185              
186             Parameters:
187              
188             =for html
189              
190             =over
191              
192             =item project
193              
194             Project that this stream will be created in
195              
196             =item opts
197              
198             Options: Additional options to use (e.g. -baseline/-readonly)
199              
200             =back
201              
202             =for html
203              
204             Returns:
205              
206             =for html
207              
208             =over
209              
210             =item $status
211              
212             Status from cleartool
213              
214             =item @output
215              
216             Ouput from cleartool
217              
218             =back
219              
220             =for html
221              
222             =cut
223              
224 0 0         return (0, ()) if $self->exists;
225              
226 0   0       $opts ||= '';
227              
228 0           $self->{readonly} = $opts =~ /-readonly/;
229              
230             return $Clearcase::CC->execute ("mkstream $opts -in "
231             . $project->name . '@'
232             . $self->{pvob}->tag . ' '
233             . $self->name . '@'
234 0           . $self->{pvob}->tag);
235             } # create
236              
237             sub remove () {
238 0     0 1   my ($self) = @_;
239              
240             =pod
241              
242             =head2 remove
243              
244             Removes UCM Stream
245              
246             Parameters:
247              
248             =for html
249              
250             =over
251              
252             =back
253              
254             =for html
255              
256             Returns:
257              
258             =for html
259              
260             =over
261              
262             =item $status
263              
264             Status from cleartool
265              
266             =item @output
267              
268             Ouput from cleartool
269              
270             =back
271              
272             =for html
273              
274             =cut
275              
276             return $Clearcase::CC->execute (
277 0           'rmstream -f ' . $self->{name} . '@' . $self->{pvob}->name);
278             } # rmStream
279              
280             sub rebase($;$) {
281 0     0 1   my ($self, $opts) = @_;
282              
283             =pod
284              
285             =head2 rebase
286              
287             Rebases a UCM Stream
288              
289             Parameters:
290              
291             =for html
292              
293             =over
294              
295             =item baseline
296              
297             Baseline to rebase to
298              
299             =item opts
300              
301             Any additional opts
302              
303             =back
304              
305             =for html
306              
307             Returns:
308              
309             =for html
310              
311             =over
312              
313             =item $status
314              
315             Status from cleartool
316              
317             =item @output
318              
319             Ouput from cleartool
320              
321             =back
322              
323             =for html
324              
325             =cut
326              
327 0   0       $opts ||= '';
328              
329 0           $opts .= ' -stream ' . $self->name . '@' . $self->{pvob}->name;
330              
331 0           return $Clearcase::CC->execute ("rebase $opts");
332             } # rebase
333              
334             sub recommend($) {
335 0     0 1   my ($self, $baseline) = @_;
336              
337             =pod
338              
339             =head2 recommend
340              
341             Recommends a baseline in a UCM Stream
342              
343             Parameters:
344              
345             =for html
346              
347             =over
348              
349             =item baseline
350              
351             Baseline to recommend
352              
353             =back
354              
355             =for html
356              
357             Returns:
358              
359             =for html
360              
361             =over
362              
363             =item $status
364              
365             Status from cleartool
366              
367             =item @output
368              
369             Ouput from cleartool
370              
371             =back
372              
373             =for html
374              
375             =cut
376              
377             return $Clearcase::CC->execute ("chstream -recommended $baseline "
378             . $self->name . '@'
379 0           . $self->{pvob}->tag);
380             } # recommend
381              
382             sub nrecommended() {
383 0     0 0   my ($self) = @_;
384              
385             =pod
386              
387             =head2 nrecommend
388              
389             Changes stream to not have a recommended baseline
390              
391             Parameters:
392              
393             =for html
394              
395             =over
396              
397             =item none
398              
399             =back
400              
401             =for html
402              
403             Returns:
404              
405             =for html
406              
407             =over
408              
409             =item $status
410              
411             Status from cleartool
412              
413             =item @output
414              
415             Ouput from cleartool
416              
417             =back
418              
419             =for html
420              
421             =cut
422              
423             return $Clearcase::CC->execute (
424 0           'chstream -nrecommended ' . $self->name . '@' . $self->{pvob}->tag);
425             } # nrecommended
426              
427             sub baselines () {
428 0     0 1   my ($self) = @_;
429              
430             =pod
431              
432             =head2 baselines
433              
434             Returns baseline objects associated with the stream
435              
436             Parameters:
437              
438             =for html
439              
440             =over
441              
442             =item none
443              
444             =back
445              
446             =for html
447              
448             Returns:
449              
450             =for html
451              
452             =over
453              
454             =item @baselines
455              
456             An array of baseline objects for this stream
457              
458             =back
459              
460             =for html
461              
462             =cut
463              
464 0           my $cmd = "lsbl -short -stream $self->{name}\@$self->{pvob}";
465              
466 0           $Clearcase::CC->execute ($cmd);
467              
468 0 0         return if $Clearcase::CC->status;
469              
470 0           my @baselines;
471              
472 0           for ($Clearcase::CC->output) {
473 0           my $baseline = Clearcase::UCM::Baseline->new ($_, $self->{pvob});
474              
475 0           push @baselines, $baseline;
476             } # for
477              
478 0           return @baselines;
479             } # baselines
480              
481             sub exists() {
482 0     0 1   my ($self) = @_;
483              
484             =pod
485              
486             =head3 exists
487              
488             Return true if the stream exists - false otherwise
489              
490             Paramters:
491              
492             =for html
493              
494             =over
495              
496             =item none
497              
498             =back
499              
500             =for html
501              
502             Returns:
503              
504             =for html
505              
506             =over
507              
508             =item boolean
509              
510             =back
511              
512             =for html
513              
514             =cut
515              
516             my ($status, @output) = $Clearcase::CC->execute (
517 0           'lsstream ' . $self->{name} . '@' . $self->{pvob}->name);
518              
519 0           return !$status;
520             } # exists
521              
522             1;
523              
524             =head1 DEPENDENCIES
525              
526             =head2 Modules
527              
528             =over
529              
530             =item L
531              
532             =item L
533              
534             =item L
535              
536             =back
537              
538             =head1 INCOMPATABILITIES
539              
540             None
541              
542             =head1 BUGS AND LIMITATIONS
543              
544             There are no known bugs in this module.
545              
546             Please report problems to Andrew DeFaria .
547              
548             =head1 COPYRIGHT AND LICENSE
549              
550             Copyright (C) 2020 by Andrew@DeFaria.com
551              
552             This library is free software; you can redistribute it and/or modify
553             it under the same terms as Perl itself, either Perl version 5.38.0 or,
554             at your option, any later version of Perl 5 you may have available.
555              
556             =cut