I am struggling to modify an existing Perl script 
that was originally written for a Unix version of
ClearCase (SCM tool). 

The script is supposed provide "keyword expansion"
functionality for files that are checked into the SCM
system.

My task is to make the same script run on Windows and
I am not having too much luck.

The script compiles without errors but it is NOT
expanding and writing the keyword values to the file
when it is checked back into Clearcase. 

Can anyone point me in right direction...

TIA.

Amad. 


##############
use strict;
use warnings;

use Env;

##EJM begin added to fix warnings/errors
my $log_expand = 0;
my $fulldate = 0;
my $basename = 0;
my $newident = "\$Id: ...\$";
my $user = "amad";
##EJM End

my $copyright = "";

#if (-f "NO_EXPAND")
#{
#    print "*** NOTICE *** - Not expanding
keywords...\n";
#exit 0;
#}

system("clearprompt proceed -mask proceed -prompt
\"Test to see if the script is firing...\"");

$log_expand=1;

#if(-f "NO_LOG_EXPAND" eq "No")
#{
    $log_expand=0;
#    print "*** NOTICE *** - Not expanding
\$Log\$keyword\n";
#}
my $c = "c:\\Program
Files\\Rational\\ClearCase\\bin\\cleartool.exe";

# create nice alias for ClearCase environment vars

my $opkind = $ENV{'CLEARCASE_OP_KIND'};
my $idstr =  $ENV{'CLEARCASE_ID_STR'};
my $eltype = $ENV{'CLEARCASE_ELTYPE'};
my $file = $ENV{'CLEARCASE_XPN'};
my $comment = $ENV{'CLEARCASE_COMMENT'};
my $no_log = $ENV{'NO_LOG'};

#print "$file = $ENV{'CLEARCASE_XPN'}";
#print "$idstr =  $ENV{'CLEARCASE_ID_STR'}";

# only process keywords for text_file
#
if ($eltype ne "text_file")
{
exit 0;
}

# make a standard date string
#
chop ($fulldate=`date '+%d-%h-%Y %H:%M'`);
chop ($copyright=`date '+%Y'`);
$copyright = "\$Copyright: (C) ".$copyright." My
Company, Inc. \$";


# remove all but the basename of $file
#

($basename = $file) = [EMAIL PROTECTED]/@@;

# create an Id expansion based on the ClearCase
operation type
#
if ($opkind eq "checkin")
{
    $newident = "\$Id: [EMAIL PROTECTED]@$idstr  \$";

exit 0;
}

#elsif ($opkind eq "checkout")
#{
#    $newident = "\$Id: CHECKEDOUT [EMAIL PROTECTED]@$idstr
  \$";
#}

my $found_id = 0;
my $found_log = 0;

my $outfile = "$file.$$";
if (!open (IN, $file)) {

exit 0;
}
open (OUT, ">$outfile") || die "Cannot create out
file";

# read in the source file, expand keywords and write
the result
# back out
#

while (<IN>)
{
# expand the Id keyword
       if ($found_id == 0 && /\$Id.*\$/)
        {
            s/\$Id.*\$/$newident/;
            $found_id = 1;
        }
        print OUT  $_;
}
# expand the Copyright keyword
        #
        if (/\$Copyright.*\$/) {
                s/\$Copyright.*\$/$copyright/;
        }
        # for a checkin operation we look to expand
the Log keyword
        #
        if ($log_expand == 1) {
                if (/\$Log\$/) {
                        if ($opkind eq "checkin") {
                                                        }
                                                }
                                        }

# remember all the stuff from the beginning of the
line to the Log keyword
# so that when we create a multiline expansion we can
prefix each of our
# lines with the same junk, presumably some language's
comment characters

(my $prefix) = /(^.*)\$Log\$/;

# close everthing up

close (IN);
close (OUT);

rename ($file, "$file.bak") || die "Cannot rename
$file to $file.bak";
rename ($outfile, $file) || die "Cannot rename files";
unlink ("$file.bak") || die "Cannot remove $file.bak";

if ($found_id == 0)
{
   print "*** NOTICE - $file does not contain a \$Id\$
keyword\n";
}

if ($log_expand == 1 && $found_log == 0)

{
   print "*** NOTICE - $file does not contain a
\$Log\$ keyword\n";

}

# tell ClearCase to continue

exit 0;



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to