keyword expansion script



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) = ~s@.*/@@;

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

exit 0;
}

#elsif ($opkind eq "checkout")
#{
# $newident = "\$Id: CHECKEDOUT $basename\@\@$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
.



Relevant Pages

  • Re: keyword expansion script
    ... ClearCase (SCM tool). ... expanding and writing the keyword values to the file ... when it is checked back into Clearcase. ... # read in the source file, expand keywords and write ...
    (perl.beginners)
  • Re: Attempt to execute script radon as a function
    ... radon.m starts with a the function keyword. ... Radon function which is a part of image processing toolbox. ... "Attempt to execute script radon as a function in line number..." ...
    (comp.soft-sys.matlab)
  • Re: read text file
    ... I'm a Filemaker newbie. ... (one keyword per line), search each keyword in certain fields ... You would script a loop through all of the records in the Keyword ... create another field in Gene to set as a flag if the word is there. ...
    (comp.databases.filemaker)
  • Re: status on Homepage
    ... I want to integrate a status on my (business) Homepage ... place a .htaccess file containing the keyword "deny from all" in it. ... make sure your changestatus.php script ONLY reacts to the "on" ...
    (comp.lang.php)
  • Re: perl grep problem
    ... > basically the script reads all the data from files in a directory into ... > an array. ... > works fine) and $ARGVis the user input word to search for. ... > inputs the keyword to search for and we loop step 2 as many times as ...
    (comp.lang.perl.misc)