I'm sending you the slightly improved code for keeping a checked out copy,
using loginfo and autoexport filter, based on code from CVS Infopages,
http://www.cvshome.org/dev/text2/sklar


CVSROOT/loginfo has something like

DEFAULT        (cat > /tmp/cvs.exp.$USER 2>&1; (sleep 2; \
/www/webpage_update.pl %{sVv} < /tmp/cvs.exp.$USER) &)

The tempfile and "sleep 2" is to avoid lock-contention issues, as in the
original article. ATTENTION: there is %{sVv} instead of %s!



P.S. I'm novice in Perl, so please excuse my lack of programming skills.
This script is by no means complete, and it needs improving.

See also the patch submitted to info-cvs list by
Gianni Mariani <[EMAIL PROTECTED]>.


P.P.S. I would be grateful, if copies of any replies were send to my
private e-mail, [EMAIL PROTECTED], because I am not subscribed to
[EMAIL PROTECTED] mailing list.

-- 
Jakub Narębski                      mailto:[EMAIL PROTECTED]
    Poland
#!/usr/bin/perl -w

my($cvsRoot)         = '/opt/cvsroot/';
my($exportDir)       = '/opt/httpd/html/cift/';
my(@importFiles)     = qw();
my(@files_to_unlink) = qw();
my(@files_to_export) = qw();
my($subDir)          = "";
my($fileList)        = "";

#
# make argv[0] into a list of files
# first token is the subdirectory
#
if ($ARGV[0] =~ /^(\S+?) (.+)$/) {
    $subDir = $1;
    
    my($rest) = $2;
    
    # in case of 'import' we have to parse input
    if ($rest eq "- Imported sources") {
        while(<STDIN>) {
            chomp;
            if ($_ =~ /^Update of /) { # not really needed
                $subDir = $_;
                $subDir =~ s/^Update of $cvsRoot//;
            } elsif ($_ =~ /^(U|N) (\S+)$/) { # can lead astray for some log messages 
                my $fname = $2;
                $fname =~ s|//+|/|g;
                push(@importFiles, $fname);
            }
        }

        # new (marked with N flag) files need not to be removed
        @files_to_unlink = @importFiles;
        @files_to_export = @importFiles;
    } elsif ($rest eq "- New directory") {
        # is this really needed?
        push(@files_to_export, $subDir);
    } elsif ($rest =~ /^- /) {
        die "Unknown argument";
    } else {
        my(@fileInfo) = split(' ', $rest);

        foreach my($fileInfo) (@fileInfo) {
            my ($fname, $in_rev, $out_rev) = split(',', $fileInfo);
            unless (defined $out_rev) {
                $out_rev = $in_rev;
                undef $in_rev;
            }
            push(@files_to_unlink, $subDir . "/" . $fname) unless ($in_rev  eq 
"NONE");
            push(@files_to_export, $subDir . "/" . $fname) unless ($out_rev eq 
"NONE");
        }
    }
} else {
    die "No arguments";
}

#
# remove any existing versions of the files
#
unlink(map {$exportDir.'/'.$_ } @files_to_unlink);

#
# export the files
#
$fileList = join(' ',@files_to_export);
umask 002; # umask command is available only in csh and bash shells
my($output) = `cd $exportDir; /usr/bin/cvs -d $cvsRoot export -D now $fileList`;

Reply via email to