Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
###############################################################################
2
# CLASS Clearcase::CheckinCmd
3
# This class inherits from the CCCmpdProc and executes the cleartool command
4
# "checkin" with no default args, args can be set
5
#
6
# It Does not override CCProcess, it runs in no processing mode so output is printed
7
# directly.
8
###############################################################################
9
 
10
package Clearcase::CheckinCmd;
11
 
12
use strict;
13
use DeployUtils::Logger;
14
use Clearcase::CmdProc;
15
 
16
use vars qw( @ISA );
17
 
18
@ISA = qw( Clearcase::CmdProc );
19
 
20
#==============================================================================
21
#   Constructor
22
#==============================================================================
23
sub new
24
{
25
    my $obclass = shift;
26
    my $class = ref($obclass) || $obclass;
27
    my $args = "";
28
 
29
    LogDebug("Clearcase::CheckinCmd::new Instantiating new object of class $class");
30
 
31
    # Call base class's constructor
32
    my $self = $class->SUPER::new();
33
 
34
    # set Cmd to do no processing
35
    $self->processOutput(0);
36
    $self->abortOnError(0);
37
 
38
    # Add this class's data to the class object
39
    $self->{_FILELIST} = [];
40
    $self->{_EXECINDIVIDUAL} = 0;
41
    $self->{_EXECMSG} = "";
42
 
43
    bless($self, $class);
44
 
45
    # set Clearcase command and arg
46
    $self->CCcmd("checkin");
47
    foreach my $newarg ( @_ )
48
    {
49
        $args .= " " . $newarg;
50
    }
51
    $self->CCargs($args);
52
 
53
    return $self;
54
}   # new
55
 
56
 
57
#==============================================================================
58
#   executeIndividually
59
# Sets the execIndividual flag to 0 or 1.  If 0 runs the checkin command once 
60
# with all supplied files in the arg list.  If 1 runs checkin command for each file.
61
#==============================================================================
62
sub executeIndividually
63
{
64
    my $self = shift;
65
 
66
    if ( @_ )
67
    {
68
        my $val = shift;
69
        $self->{_EXECINDIVIDUAL} = ( $val == 0 ) ? 0 : 1;
70
        LogDebug("ClearCase::CheckinCmd::executeIndividually Set to $self->{_EXECINDIVIDUAL}");
71
    }
72
    return $self->{_EXECINDIVIDUAL};
73
 
74
}   # executeIndividually
75
 
76
 
77
#==============================================================================
78
#   execMsg
79
# Sets the message to display before executing the command
80
#==============================================================================
81
sub execMsg
82
{
83
    my $self = shift;
84
 
85
    if ( @_ )
86
    {
87
        $self->{_EXECMSG} = shift;
88
        LogDebug("ClearCase::CheckinCmd::execMsg Set to $self->{_EXECMSG}");
89
    }
90
    return $self->{_EXECMSG};
91
}   # execMsg
92
 
93
 
94
#==============================================================================
95
#   addFiles
96
# Adds files to list of files to checkin
97
#==============================================================================
98
sub addFiles
99
{
100
    my $self = shift;
101
 
102
    map { $_ = "\"$_\"" } @_;
103
    LogDebug("Clearcase::CheckinCmd::addFiles Added Files " . join(",", @_));
104
    push( @{$self->{_FILELIST}}, @_);
105
}   # addFiles
106
 
107
 
108
#==============================================================================
109
#   getNumFiles
110
# Returns number of files in file list
111
#==============================================================================
112
sub getNumFiles
113
{
114
    my $self = shift;
115
 
116
    return $#{$self->{_FILELIST}};
117
}   # getNumFiles
118
 
119
 
120
#==============================================================================
121
#   CCexecute
122
# Overrides base class version.
123
# It simply appends files to args and calls the base class execute.  
124
# If there are no files it returns without running
125
#==============================================================================
126
sub CCexecute
127
{
128
    my $self = shift;
129
    my $retval = 0;
130
 
131
    if ( $#{$self->{_FILELIST}} >= 0 )
132
    {
133
        if ( $self->{_EXECINDIVIDUAL} )
134
        {
135
            my $orgArgs = $self->CCargs();
136
            foreach my $file ( @{$self->{_FILELIST}} )
137
            {
138
                LogNorm("Checking in File $file.  $self->{_EXECMSG}");
139
                $self->CCargs($orgArgs . " " . $file);
140
                $retval = $self->SUPER::CCexecute();
141
            }
142
        }
143
        else
144
        {
145
            LogNorm($self->{_EXECMSG}) if ( $self->{_EXECMSG} ne "" );
146
            $self->CCaddArgs(@{$self->{_FILELIST}});
147
            $retval = $self->SUPER::CCexecute();
148
        }
149
    }
150
    else
151
    {
152
        LogInfo("Clearcase::CheckinCmd::CCexecute No execution as no Files supplied");
153
    }
154
 
155
    return $retval;
156
}   # CCexecute