# perl script to parse out the output of p4 integ -n # to determine who has the responsibility to merge # remaining files # This script assumes that the token 'BUGXXXXX' appears # in the change description and then produces a report # sorted by bug number and perforce username. # usage: # %tobemerged.pl # # assumes: # p4 is in path # usage is correct (no error checking) # akalaveshi@mahinetworks.com unless ($ARGV[0] && $ARGV[1]) { print "Missing/wrong number of arguments.\n"; print "usage:\n\%tobemerged.pl \n"; exit; } my(@integ) = `p4 integ -n -i -d $ARGV[0] $ARGV[1]`; my (@files, %users); for $i (0..$#integ) { # need to have a range (i.e. #5,#5) $integ[$i] =~ s/([^,])\#(\d+)$/$1\#$2,\#$2/; my ($range1, $range2); my ($to, $from); if ($integ[$i] =~ /(\/\/.*) - .* from (\/\/.*)/) { $to = $1; $from = $2; } else { die "Parsing error: $integ[$i]\n\n"; } chomp ($from); if ($from =~ /(.*)#(\d+),#(\d+)/) { $from = $1; $range1 = $2; $range2 = $3; } else { print "incorrect parsing\n"; } $to =~ s/#\d+$//; for my $i ($range1..$range2) { my (@test) = `p4 integ -n -i -d $from#$i,#$i $to 2>&1`; unless (grep (/already integrated/, @test)) { push (@files, "$from#$i,#$i"); } } } for $i (0..$#files) { @temp = `p4 changes -l $files[$i]`; my ($found) = 0; foreach (@temp) { next if /^$/; # skipping blank lines if( m|^Change (\d+) on [0-9/]+ by (.*)@| ) { $change = $1; # capture change number $user = $2; # capture user next; } elsif( @bugs = /BUG(\d{5})/g ) { foreach $bug ( @bugs ) { push (@{$users{$user}{$bug}}, $files[$i]." (change $change)"); } $found = 1; } if (! $found) { push (@{$users{$user}{'No Bug #'}}, $files[$i]." (change $change)"); } } } my (@emails); foreach (keys(%users)) { $output = `p4 users $_`; if ($output =~ /<(.*\@.*)>/) { push(@emails,$1); } } print "TO:\n".join(";",@emails)."\n\n\n"; print "NAME\tBUG\t\FILE (perforce change number)\n\n"; foreach $name (sort(keys(%users))) { print "$name\n"; # print name foreach $b (sort(keys(%{$users{$name}}))) { print "\t$b\n"; # print bug number # sort unique undef %saw; @saw{@{${$users{$name}}{$b}}} = (); @sorted_files = sort keys %saw; # foreach $f (@sorted_files) { print "\t\t$f\n"; #print files } } }