#!/usr/local/bin/perl -w ################################################################################# # # # Author: Michael Alessio malessio@perforce.com # # # # This script is provided as a prototype only and I do not garantee that it # # will work for you. While feedback and bug reports are apreciated, I do not # # garantee that I will address them (but I might :-) # # # # This script will take a job number and a branchspec and will integrate all # # fixes associated with that job using the supplied branch spec. # # # # Caveat: # # CLI Only. I hope to make it run from the tools menu in a future release # # # # Usage: # # Run the script and supply the Job number and the branch spec. # # # ################################################################################# use strict; use warnings; my $job; my $destination; my $line; my $i; my $j; my $changelist; my $numofloops; my @changelist_array; my @file_array; my @p4command_string; # # Get job and destination from user # print "Job to integrate: "; $job=; chomp($job); print "\n"; print "Branch Spec: "; $destination=; chomp($destination); print "\n"; # # create a new changelist # print "p4 change -i\n"; print "Change: new\n"; print "Description: integration of Job: $job using Branchspec: $destination\n"; open P4PIPE, "| p4 change -i > p4integjob.txt"; print P4PIPE "Change: new\n"; print P4PIPE "Description: Integration of Job: $job using Branchspec: $destination\n"; close P4PIPE; open(p4Results,"p4integjob.txt"); while($line=){ chomp($line); if (($changelist) = ($line =~ /^Change (\d+) created\.$/)){ print "Changelist $changelist created\n"; } } close(p4Results); # # Find changelists fixed by that job # print "Executing p4 fixes -j $job\n"; open P4PIPE, "p4 fixes -j $job |"; $i=0; while( $line = ){ chomp($line); if (($changelist_array[$i]) = ($line =~ /^.{26}(\d+).*$/)){ print "Changelist $changelist_array[$i]\n"; } $i=$i+1; } $numofloops = $i; # # integrate files from changelist # $i=0; $j=0; while ($i < $numofloops){ print "Executing p4 describe -s $changelist_array[$i]\n"; open P4PIPE, "p4 describe -s $changelist_array[$i] |"; while( $line = ){ chomp($line); if ($line eq "Affected files ..."){ $line = ; while( $line = ){ chomp($line); if (($file_array[$j]) = ( $line =~ /^\.\.\.\s(.*)#\d* \w*$/ )){ $p4command_string[$j] = "p4 integrate -c $changelist -d -b $destination -s $file_array[$j]" . "@". "$changelist_array[$i]" . ",@" . "$changelist_array[$i]"; $j=$j+1; } } } } $i=$i+1; } $numofloops = $j; $j=0; while ($j < $numofloops){ print "Executing: $p4command_string[$j]\n"; open P4PIPE, "$p4command_string[$j] |"; while( $line = ){} $j=$j+1; }