Add CVS 1.12.11.
[dragonfly.git] / contrib / cvs-1.12.11 / contrib / commit_prep.in
1 #! @PERL@
2 # -*-Perl-*-
3 #
4 # Perl filter to handle pre-commit checking of files.  This program
5 # records the last directory where commits will be taking place for
6 # use by the log_accum.pl script.
7 #
8 # IMPORTANT: this script interacts with log_accum, they have to agree
9 # on the tmpfile name to use.  See $LAST_FILE below.
10 #
11 # Contributed by David Hampton <hampton@cisco.com>
12 # Stripped to minimum by Roy Fielding
13 #
14 ############################################################
15 $TMPDIR        = $ENV{'TMPDIR'} || '/tmp';
16 $FILE_PREFIX   = '#cvs.';
17
18 # If see a "-u $USER" argument, then destructively remove it from the
19 # argument list, so $ARGV[0] will be the repository dir again, as it
20 # used to be before we added the -u flag.
21 if ($ARGV[0] eq '-u') {
22   shift @ARGV;
23   $CVS_USERNAME = shift (@ARGV);
24 }
25
26 # This needs to match the corresponding var in log_accum.pl, including
27 # the appending of the pgrp and username suffixes (see uses of this
28 # var farther down).
29 $LAST_FILE = "$TMPDIR/${FILE_PREFIX}lastdir";
30
31 sub write_line {
32     my ($filename, $line) = @_;
33
34 # A check of some kind is needed here, but the rules aren't apparent
35 # at the moment:
36
37 #    foreach($filename, $line){ 
38 #        $_ =~ m#^([-\@\w.\#]+)$#;
39 #        $_ = $1;
40 #    }
41
42     open(FILE, ">$filename") || die("Cannot open $filename: $!\n");
43     print(FILE $line, "\n");
44     close(FILE);
45 }
46
47 #
48 # Record this directory as the last one checked.  This will be used
49 # by the log_accumulate script to determine when it is processing
50 # the final directory of a multi-directory commit.
51 #
52 $id = getpgrp();
53
54 &write_line("$LAST_FILE.$id.$CVS_USERNAME", $ARGV[0]);
55
56 exit(0);