summaryrefslogtreecommitdiffstats
path: root/scripts/cvs-clean
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitbd9e6617827818fd043452c08c606f07b78014a0 (patch)
tree425bb4c3168f9c02f10150f235d2cb998dcc6108 /scripts/cvs-clean
downloadtdesdk-bd9e6617827818fd043452c08c606f07b78014a0.tar.gz
tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdesdk@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'scripts/cvs-clean')
-rwxr-xr-xscripts/cvs-clean90
1 files changed, 90 insertions, 0 deletions
diff --git a/scripts/cvs-clean b/scripts/cvs-clean
new file mode 100755
index 00000000..f6ae254d
--- /dev/null
+++ b/scripts/cvs-clean
@@ -0,0 +1,90 @@
+#! /usr/bin/env perl
+
+#
+# This script recursively (beginning with the current directory)
+# wipes out everything not registered in CVS.
+#
+# written by Oswald Buddenhagen <ossi@kde.org>
+# inspired by the "old" cvs-clean target from Makefile.common
+#
+# This file is free software in terms of the modified BSD licence.
+# See kdelibs/doc/common/bsd-license.html for the exact conditions.
+#
+
+use File::Path;
+
+my $dry_run = 0;
+
+sub newfiles()
+{
+ my ($indir, $incvs) = @_;
+ for my $n (keys (%$incvs)) { delete $$indir{$n} }
+ return sort (keys (%$indir));
+}
+
+sub cvsclean()
+{
+ my $dir = shift;
+ my (%dirsdir, %filesdir, %dirscvs, %filescvs);
+ my $dnam = $dir ? $dir : ".";
+ if (!opendir (DIR, $dnam)) {
+ print STDERR "Cannot enter \"".$dnam."\".\n";
+ return;
+ }
+ for my $fn (grep (!/^\.\.?$/, readdir (DIR))) {
+ if (-d $dir.$fn) {
+ $fn eq "CVS" or $dirsdir{$fn} = 1;
+ } else {
+ $filesdir{$fn} = 1;
+ }
+ }
+ closedir (DIR);
+ if (!open (FILE, "<".$dir."CVS/Entries")) {
+ print STDERR "No CVS information in \"".$dnam."\".\n";
+ return;
+ }
+ while (<FILE>) {
+ m%^D/([^/]+)/.*$% and $dirscvs{$1} = 1;
+ m%^/([^/]+)/.*$% and $filescvs{$1} = 1;
+ }
+ close (FILE);
+ if (open (FILE, "<".$dir."CVS/Entries.Log")) {
+ while (<FILE>) {
+ m%^A D/([^/]+)/.*$% and $dirscvs{$1} = 1;
+ m%^A /([^/]+)/.*$% and $filescvs{$1} = 1;
+ m%^R D/([^/]+)/.*$% and delete $dirscvs{$1};
+ m%^R /([^/]+)/.*$% and delete $filescvs{$1};
+ }
+ close (FILE);
+ }
+ for my $fn (&newfiles (\%filesdir, \%filescvs)) {
+ print ("F ".$dir.$fn."\n");
+ unlink($dir.$fn) unless $dry_run;
+ }
+ for my $fn (&newfiles (\%dirsdir, \%dirscvs)) {
+ print ("D ".$dir.$fn."\n");
+ rmtree($dir.$fn, 0, 0) unless $dry_run;
+ }
+ for my $fn (sort (keys (%dirscvs))) {
+ &cvsclean ($dir.$fn."/");
+ }
+}
+
+my $usage =
+ "usage: cvs-clean [options]\n".
+ " --help | -h print usage information\n".
+ " --dry-run | -n print intended actions; don't change filesystem\n";
+
+foreach my $arg (@ARGV) {
+ if ($arg eq '-h' || $arg eq '--help') {
+ print $usage;
+ exit (0);
+ } elsif ($arg eq '-n' || $arg eq '--dry-run') {
+ $dry_run = 1;
+ } else {
+ print STDERR "cvs-clean: unknown argument '".$arg."'\n\n".$usage;
+ exit (1);
+ }
+}
+
+&cvsclean ("");