#!/usr/local/bin/perl # Delete a p4 controlled library $lib=$ARGV[0]; $client=$ARGV[1]; local($p4) = "p4"; # First get all the opened files $dlist=0; open(CL, ">/tmp/p4cl.$lib") || die ; print(CL "\nChange: new\n\Description: $lib delete\n\n\nFiles:\n\t"); open(OPENED, "$p4 -c $client opened|") || next; while() { { # is it add or edit (@mode)=split; ($depotfile)=split('#', $mode[0]); $p4mode=$mode[2]; if($p4mode eq "add") { # revert it system("$p4 -c $client revert $depotfile"); $dlist{$depotfile}=1; next; } if($p4mode eq "delete") { print(CL "\t$depotfile\n"); $dlist{$depotfile}=1; next; } if($p4mode eq "edit") { # mark it for delete # write it into the change list system("$p4 -c $client revert $depotfile; $p4 -c $client delete $depotfile"); print(CL "\t$depotfile\n"); $dlist{$depotfile}=1; next; } } } close(OPENED); open(HAVE, "$p4 -c $client have|") || next; while() { { ($depotfilev)=split; ($depotfile)=split('#', $depotfilev); if($dlist{$depotfile} eq 1) { #print "Skipping $depotfile\n"; next; } system("$p4 -c $client delete $depotfile"); print(CL "\t$depotfile\n"); } } print (CL "\n"); close(CL); # submit the changelist system("$p4 -c $client submit -i < /tmp/p4cl.$lib"); system("rm /tmp/p4cl.$lib"); system("$p4 client -d $client");