[p4] Modifying Changelist form

Ivey, William william_ivey at bmc.com
Tue Aug 11 10:18:54 PDT 2009


My "reviewer" trigger looks for the the string that's normally
only found in new change forms: "<enter description here>" so it
won't add the "reviewed by" line again to an existing change
form. It's written for bourne shell (standard for our triggers)
and uses the sed command, but otherwise it is very similar to
what you have:

sed -e "s/<enter description here>/&\n\n# Fill in reviewer's name\
 below\nReviewer: <name>/" "$formFile" > "$TMPFILE"

(The & inserts the matched text, then follows it with a blank
line, a comment, and the Reviewer: field.

-Wm


-----Original Message-----
From: perforce-user-bounces at perforce.com [mailto:perforce-user-bounces at perforce.com] On Behalf Of Kamlesh Mutha
Sent: Saturday, August 08, 2009 3:39 AM
To: Perforce Users Mailing List
Subject: [p4] Modifying Changelist form

Hi All,

Objective is to insert "ReviewedBy" field text in every changelist form.
This is what I have done and seems to be working fine in my test setup.

Trigger Script:

#!/usr/bin/perl
$formfile = $ARGV[0];  # from %formfile% in trigger table

$defaultin = "^Description:";
$defaultout = "Description:\n\tReviewedBy =>\n";

# Build a modified workspace spec based on contents of %formfile%
$modifiedform = "";
open FORM, $formfile or die "Trigger couldn't read form tempfile";
while ( <FORM> )
{       ## Do the substitution as appropriate.
        if ( m:$defaultin: ) { $_ = "$defaultout"; }
        $modifiedform .= $_;
}
# Write the modified spec back to the %formfile%,
open MODFORM, ">$formfile" or die "Couldn't write form tempfile";
print MODFORM $modifiedform;
exit 0;
[ Snippet of the script from perforce site ]

Triggers setup :

Triggers:
        reviwer form-out change "/home/builduser/modify_change.pl
%formfile%"


Does this look alright or is there any better way to do it?

Thanks and Regards,
Kamlesh





-- 
Faith waiting in the heart of a seed promises a miracle of life which it can
not prove!
-Ravindranath Tagore
_______________________________________________
perforce-user mailing list  -  perforce-user at perforce.com
http://maillist.perforce.com/mailman/listinfo/perforce-user




More information about the perforce-user mailing list