X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=lib%2FClearcase%2FUCM%2FStream.pm;h=618e661c9c57f9e3ce583f67cade829b3db7f6c1;hb=1e8dca4ff946b0b69754519e140ab4fc29335b0d;hp=0cdc19831b9575a327a941642fa7c1a8f6ca9b7a;hpb=81cbd130706633b1c19ff59371c2ef61d80c562b;p=clearscm.git diff --git a/lib/Clearcase/UCM/Stream.pm b/lib/Clearcase/UCM/Stream.pm index 0cdc198..618e661 100644 --- a/lib/Clearcase/UCM/Stream.pm +++ b/lib/Clearcase/UCM/Stream.pm @@ -28,9 +28,9 @@ $Date: 2011/11/15 02:00:58 $ =head1 SYNOPSIS -Provides access to information about Clearcase Elements. +Provides access to information about Clearcase Streams. - my $stream= new Clearcase::UCM::Stream ($name, $pvob); + my $stream = new Clearcase::UCM::Stream ($name, $pvob); =head1 DESCRIPTION @@ -47,11 +47,8 @@ package Clearcase::UCM::Stream; use strict; use warnings; -use Clearcase; -use Clearcase::UCM::Baseline; - sub new ($$) { - my ($class, $stream, $pvob) = @_; + my ($class, $name, $pvob) = @_; =pod @@ -65,10 +62,14 @@ Parameters: =over -=item stream name +=item name Name of stream +=item pvob + +Associated pvob + =back =for html @@ -87,17 +88,17 @@ Returns: =cut - my $self = bless { - name => $stream, - pvob => Clearcase::vobtag $pvob, + $class = bless { + name => $name, + pvob => $pvob, }, $class; # bless - - return $self; + + return $class; } # new - + sub name () { my ($self) = @_; - + =pod =head2 name @@ -135,7 +136,7 @@ Returns: sub pvob () { my ($self) = @_; - + =pod =head2 pvob @@ -170,9 +171,9 @@ Returns: return $self->{pvob}; } # pvob - -sub create ($$;$$) { - my ($self, $project, $pvob, $baseline, $opts) = @_; + +sub create ($;$) { + my ($self, $project, $opts) = @_; =pod @@ -186,21 +187,13 @@ Parameters: =over -=item UCM Project (required) - -UCM Project this stream belongs to - -=item PVOB (Required) - -Project Vob +=item project -=item baseline - -Baseline to set this stream to +Project that this stream will be created in =item opts -Options: Additional options to use (e.g. -readonly) +Options: Additional options to use (e.g. -baseline/-readonly) =back @@ -226,30 +219,17 @@ Ouput from cleartool =cut - # Fill in object members - $self->{project} = $project; - $self->{pvob} = $pvob; - - # Fill in opts + return (0, ()) if $self->exists; + $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}); + + return $Clearcase::CC->execute( + "mkstream $opts -in " + . $project->name . '@' . $self->{pvob}->tag . ' ' + . $self->name . '@' . $self->{pvob}->tag + ); } # create sub remove () { @@ -267,21 +247,56 @@ Parameters: =over -=item UCM Project (required) +=back -UCM Project this stream belongs to +=for html -=item PVOB (Required) +Returns: + +=for html
-Project Vob +=over + +=item $status + +Status from cleartool + +=item @output + +Ouput from cleartool + +=back + +=for html+ +=cut + + return $Clearcase::CC->execute + ('rmstream -f ' . $self->{name} . '@' . $self->{pvob}->name); +} # rmStream + +sub rebase($;$) { + my ($self, $opts) = @_; + +=pod + +=head2 rebase + +Rebases a UCM Stream + +Parameters: + +=for html
+ +=over =item baseline -Baseline to set this stream to +Baseline to rebase to =item opts -Options: Additional options to use (e.g. -readonly) +Any additional opts =back @@ -307,9 +322,106 @@ Ouput from cleartool =cut - return $Clearcase::CC->execute - ('rmstream -f ' . $self->{name} . "\@" . $self->{pvob}); -} # rmStream + $opts ||= ''; + + $opts .= ' -stream ' . $self->name . '@' . $self->{pvob}->name; + + return $Clearcase::CC->execute("rebase $opts"); +} # rebase + +sub recommend($) { + my ($self, $baseline) = @_; + +=pod + +=head2 recommend + +Recommends a baseline in a UCM Stream + +Parameters: + +=for html+ +=over + +=item baseline + +Baseline to recommend + +=back + +=for html+ +Returns: + +=for html+ +=over + +=item $status + +Status from cleartool + +=item @output + +Ouput from cleartool + +=back + +=for html+ +=cut + + return $Clearcase::CC->execute( + "chstream -recommended $baseline " . $self->name . '@' . $self->{pvob}->tag + ); +} # recommend + +sub nrecommended() { + my ($self) = @_; + +=pod + +=head2 nrecommend + +Changes stream to not have a recommended baseline + +Parameters: + +=for html+ +=over + +=item none + +=back + +=for html+ +Returns: + +=for html+ +=over + +=item $status + +Status from cleartool + +=item @output + +Ouput from cleartool + +=back + +=for html+ +=cut + + return $Clearcase::CC->execute( + 'chstream -nrecommended ' . $self->name . '@' . $self->{pvob}->tag + ); +} # nrecommended sub baselines () { my ($self) = @_; @@ -349,22 +461,64 @@ An array of baseline objects for this stream =cut my $cmd = "lsbl -short -stream $self->{name}\@$self->{pvob}"; - + $Clearcase::CC->execute ($cmd); return if $Clearcase::CC->status; my @baselines; - - foreach ($Clearcase::CC->output) { + + for ($Clearcase::CC->output) { my $baseline = Clearcase::UCM::Baseline->new ($_, $self->{pvob}); - + push @baselines, $baseline; - } # foreach - + } # for + return @baselines; } # baselines +sub exists() { + my ($self) = @_; + +=pod + +=head3 exists + +Return true if the stream exists - false otherwise + +Paramters: + +=for html+ +=over + +=item none + +=back + +=for html+ +Returns: + +=for html+ +=over + +=item boolean + +=back + +=for html+ +=cut + + my ($status, @output) = $Clearcase::CC->execute( + 'lsstream ' . $self->{name} . '@' . $self->{pvob}->name + ); + + return !$status; +} # exists + 1; =head1 DEPENDENCIES @@ -374,6 +528,7 @@ An array of baseline objects for this stream =for html =for html +=for html =head1 INCOMPATABILITIES