home *** CD-ROM | disk | FTP | other *** search
- From: vixie@pa.dec.com (Paul Vixie)
- Newsgroups: alt.sources,comp.lang.perl
- Subject: mkrcs - perl script to check in a whole tree
- Message-ID: <1991Feb9.181603.16589@pa.dec.com>
- Date: 9 Feb 91 18:16:03 GMT
-
- #! /usr/local/bin/perl
-
- # mkrcs - create any missing RCS subdirectories, check in all text files
- # will use "ci -k" if there are RCS keywords in the text.
- # 09feb91 vixie@decwrl [written]
-
- chop($cwd = `pwd`);
- foreach $d (@ARGV) {
- chdir("$cwd/$d") || die "$cwd/$d: $!";
- &mkrcs();
- }
- exit 0;
-
- sub mkrcs {
- local($has_rcs) = 0;
- local(@f) = ();
- local(*d, *f);
- local($k);
-
- print "RCS'ing in ".`pwd`;
- opendir(d, '.') || die "opendir: $!";
- while ($f = readdir(d)) {
- next if ($f =~ /^\./); # begins with .
- next if (-l $f); # is a symlink
- if (-f $f) { # is a plain file
- push(@f, $f);
- next;
- }
- next if (! -d $f); # isn't a dir
- if ($f eq 'RCS') { # name is RCS
- $has_rcs++;
- next;
- }
- chdir($f) || die "$f: $!";
- &mkrcs();
- chdir('..') || die "..: $!";
- }
- if (! $has_rcs) {
- mkdir("RCS", 0777) || die "mkdir RCS: $!";
- }
- while ($f = pop(@f)) {
- open(f, "<$f") || die "$f: $!";
- next unless (-T f); # text file
- next if (-f "$f,v" || -f "RCS/$f,v"); # already in RCS
- $k = '';
- while (<f>) {
- if (/\$(Header|Version):/) {
- $k = '-k ';
- last;
- }
- }
- $_ = "ci -u $k -t/dev/null -morig $f";
- print "$_\n";
- system $_;
- } continue {
- close(f);
- }
- }
-
- --
- Paul Vixie
- DEC Western Research Lab <vixie@wrl.dec.com>
- Palo Alto, California ...!decwrl!vixie
-