############################################################################### # CLASS Clearcase::CheckinCmd # This class inherits from the CCCmpdProc and executes the cleartool command # "checkin" with no default args, args can be set # # It Does not override CCProcess, it runs in no processing mode so output is printed # directly. ############################################################################### package Clearcase::CheckinCmd; use strict; use DeployUtils::Logger; use Clearcase::CmdProc; use vars qw( @ISA ); @ISA = qw( Clearcase::CmdProc ); #============================================================================== # Constructor #============================================================================== sub new { my $obclass = shift; my $class = ref($obclass) || $obclass; my $args = ""; LogDebug("Clearcase::CheckinCmd::new Instantiating new object of class $class"); # Call base class's constructor my $self = $class->SUPER::new(); # set Cmd to do no processing $self->processOutput(0); $self->abortOnError(0); # Add this class's data to the class object $self->{_FILELIST} = []; $self->{_EXECINDIVIDUAL} = 0; $self->{_EXECMSG} = ""; bless($self, $class); # set Clearcase command and arg $self->CCcmd("checkin"); foreach my $newarg ( @_ ) { $args .= " " . $newarg; } $self->CCargs($args); return $self; } # new #============================================================================== # executeIndividually # Sets the execIndividual flag to 0 or 1. If 0 runs the checkin command once # with all supplied files in the arg list. If 1 runs checkin command for each file. #============================================================================== sub executeIndividually { my $self = shift; if ( @_ ) { my $val = shift; $self->{_EXECINDIVIDUAL} = ( $val == 0 ) ? 0 : 1; LogDebug("ClearCase::CheckinCmd::executeIndividually Set to $self->{_EXECINDIVIDUAL}"); } return $self->{_EXECINDIVIDUAL}; } # executeIndividually #============================================================================== # execMsg # Sets the message to display before executing the command #============================================================================== sub execMsg { my $self = shift; if ( @_ ) { $self->{_EXECMSG} = shift; LogDebug("ClearCase::CheckinCmd::execMsg Set to $self->{_EXECMSG}"); } return $self->{_EXECMSG}; } # execMsg #============================================================================== # addFiles # Adds files to list of files to checkin #============================================================================== sub addFiles { my $self = shift; map { $_ = "\"$_\"" } @_; LogDebug("Clearcase::CheckinCmd::addFiles Added Files " . join(",", @_)); push( @{$self->{_FILELIST}}, @_); } # addFiles #============================================================================== # getNumFiles # Returns number of files in file list #============================================================================== sub getNumFiles { my $self = shift; return $#{$self->{_FILELIST}}; } # getNumFiles #============================================================================== # CCexecute # Overrides base class version. # It simply appends files to args and calls the base class execute. # If there are no files it returns without running #============================================================================== sub CCexecute { my $self = shift; my $retval = 0; if ( $#{$self->{_FILELIST}} >= 0 ) { if ( $self->{_EXECINDIVIDUAL} ) { my $orgArgs = $self->CCargs(); foreach my $file ( @{$self->{_FILELIST}} ) { LogNorm("Checking in File $file. $self->{_EXECMSG}"); $self->CCargs($orgArgs . " " . $file); $retval = $self->SUPER::CCexecute(); } } else { LogNorm($self->{_EXECMSG}) if ( $self->{_EXECMSG} ne "" ); $self->CCaddArgs(@{$self->{_FILELIST}}); $retval = $self->SUPER::CCexecute(); } } else { LogInfo("Clearcase::CheckinCmd::CCexecute No execution as no Files supplied"); } return $retval; } # CCexecute