#!/usr/local/bin/perl # Read some old clients and map them into something else $oldproj=$ARGV[0]; $oldprojrev=$ARGV[1]; $newproj=$ARGV[2]; $newprojrev=$ARGV[3]; $site=$ARGV[4]; if($site ne "") { $dosite=1; print "Site is $site\n"; } print "Old: $oldproj old rev: $oldprojrev\n"; print "New: $newproj new rev: $newprojrev\n"; $searchstring=":".$oldproj."_".$oldprojrev; $cmd="p4 clients | grep '$searchstring ' > /tmp/cmap.$$"; print $cmd; system($cmd); open(CL,"</tmp/cmap.$$"); while(<CL>) { (@cdata)=split; $tplate=$cdata[1]; $troot=$cdata[4]; print "Template client is $tplate\n"; print "Root is $troot\n"; $newc=$tplate; if($dosite eq 1) { $source=$oldproj."_".$oldprojrev; $target=$newproj."_".$newprojrev."_".$site; } else { $source=$oldproj."_".$oldprojrev; $target=$newproj."_".$newprojrev; } $newc=~ s/$source/$target/g; print "New client is $newc\n"; # Check to see if it exists $cmd="p4 clients | grep $newc | grep -v branches"; system($cmd); print "$cmd\n"; # Good exit means it exists, don't futz with an existing client if ($? eq 0) { print "Skipping existing client\n"; $cmd="p4 -c $newc sync"; system($cmd); next; } $newroot=$troot; if($dosite eq 1) { $newroot=~ s/$oldproj\/$oldprojrev/$site\/$newproj\/$newprojrev/g; } else { $newroot=~ s/$oldproj\/$oldprojrev/$newproj\/$newprojrev/g; } print "New root is $newroot\n"; $cmd="p4 -c $tplate client -o"; open(CMD, "$cmd|") || die ; open(CMDOUT, ">/tmp/cbout") || die ; while(<CMD>) { if(/^Client/) { print CMDOUT "Client: $newc\n\n"; } if(/^Description/ && $dosite eq 1) { $dstring="Description: \n\t$newproj $newprojrev site:$site cds library\n"; print $dstring; print CMDOUT $dstring; } else { if(/^Description/) { print CMDOUT "Description: \n\t$newproj $newprojrev cds library\n"; }} if(/^Root/) { print CMDOUT "Root: $newroot\n"; } if(/^View/) { print CMDOUT "$_\n"; } if(/^\t\-{0,1}\/\/depot/) { s/$oldproj\/$oldprojrev/$newproj\/$newprojrev/g; s/$tplate/$newc/g; print CMDOUT $_; print "$_\n"; print "$tplate\n"; } } close(CMD); close(CMDOUT); $cmd="p4 -c $newc client -i < /tmp/cbout > /dev/null"; system($cmd); # let's make sure we have some files in the client # and delete the client if the files are empty $cmd="p4 -s -c $newc sync -n"; $emptyclient=0; open(P4C, "$cmd|") || die "Could not exec $cmd\n"; while(<P4C>) { if( /error: No such file/) { # delete it $emptyclient=1; } } close(P4C); if($emptyclient eq 1) { print "Deleting empty or unbranched client $newc\n"; $cmd="p4 client -d $newc"; system($cmd); } #let the autosyncer sync the remote sites if($dosite ne 1) { $cmd="p4 -c $newc sync"; system($cmd); } } close(CL);
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 5093 | Hari Krishna Dara |
Populating perforce branch. I will be adding p4admin files to it. |
||
//guest/perforce_software/cdsp4/release/2.2/Utils/clientmapper | |||||
#1 | 1705 | Shiv Sikand | Added missing utilities for branch management |