cvs2includes 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/perl
  2. #
  3. # This script finds all CVS/Entries files in the current directory and below
  4. # and creates a local .cvsinclude file with non-inherited rules including each
  5. # checked-in file. Then, use this option whenever using --cvs-exclude (-C):
  6. #
  7. # -f ': .cvsinclude'
  8. #
  9. # That ensures that all checked-in files/dirs are included in the transfer.
  10. # (You could alternately put ": .cvsinclude" into an .rsync-filter file and
  11. # use the -F option, which is easier to type.)
  12. #
  13. # The downside is that you need to remember to re-run cvs2includes whenever
  14. # you add a new file to the project.
  15. use strict;
  16. open(FIND, 'find . -name CVS -type d |') or die $!;
  17. while (<FIND>) {
  18. chomp;
  19. s#^\./##;
  20. my $entries = "$_/Entries";
  21. s/CVS$/.cvsinclude/;
  22. my $filter = $_;
  23. open(ENTRIES, $entries) or die "Unable to open $entries: $!\n";
  24. my @includes;
  25. while (<ENTRIES>) {
  26. push(@includes, $1) if m#/(.+?)/#;
  27. }
  28. close ENTRIES;
  29. if (@includes) {
  30. open(FILTER, ">$filter") or die "Unable to write $filter: $!\n";
  31. print FILTER map "+ /$_\n", @includes;
  32. close FILTER;
  33. print "Updated $filter\n";
  34. } elsif (-f $filter) {
  35. unlink($filter);
  36. print "Removed $filter\n";
  37. }
  38. }
  39. close FIND;