Perl script to change CVS Root in a directory tree
We moved our CVS to a different machine and our CVS Root thus changed. On Windows, if you use TortoiseCVS (at least), then it creates a CVS folder inside each folder of your repository and each of this CVS folders has a file called Root which has the CVS Root string. Now, I had to update each of these few hundred files with the new CVSROOT string. Perl (v5.8.4 built for MSWin32-x86-multi-thread on my system) to the rescue:
use File::Find;
find(\&wanted, "$ARGV[0]");
sub wanted
{
if($_ eq 'Root')
{
open(fp,">" . $File::Find::dir . "/" . $_);
print ">" . $File::Find::dir . "/" . $_ . "\n";
print fp "$ARGV[1]";
close(fp);
}
}
Pass the base folder name as the first argument and the new CVSROOT as the second argument.
2 comments:
Hi,
I have created a tiny tool in Java to switch the root files in one go. http://code.google.com/p/cvsrootswitch/
The script approach is the best. The tool I created is for those who want a button to do this.
with regards
Tushar
This year-old post just saved me a butt-load of time and annoyance. Thanks!
Post a Comment