Develop and Download Open Source Software

Browse CVS Repository

Contents of /geeklogjp/CVSROOT/commit_prep

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Sun Nov 26 15:14:42 2006 UTC (17 years, 4 months ago) by taca
Branch: MAIN
CVS Tags: HEAD
Add cvs mail scripts from NetBSD project.

1 #! /usr/bin/perl
2 # -*-Perl-*-
3 #
4 # Copyright (c) 2006 The NetBSD Foundation, Inc.
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # 3. All advertising materials mentioning features or use of this software
16 # must display the following acknowledgement:
17 # This product includes software developed by the NetBSD
18 # Foundation, Inc. and its contributors.
19 # 4. Neither the name of The NetBSD Foundation nor the names of its
20 # contributors may be used to endorse or promote products derived
21 # from this software without specific prior written permission.
22 #
23 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 # POSSIBILITY OF SUCH DAMAGE.
34 #
35 #ident "@(#)cvs/contrib:$NetBSD: commit_prep,v 1.9 2006/02/16 15:55:29 christos Exp $"
36 #
37 # Perl filter to handle pre-commit checking of files. This program
38 # records the last directory where commits will be taking place for
39 # use by the log_accum.pl script. Also check for unresolved merge
40 # conflicts.
41 #
42 # Contributed by David Hampton <hampton@cisco.com>
43 # Hacked on lots by Greg A. Woods <woods@web.net>
44 # Further hacked by Charles M. Hannum <mycroft@netbsd.org>
45
46 #
47 # Configurable options
48 #
49
50 # Check each file (except dot files)
51 #
52 $check_conflicts = 0;
53
54 # Constants (remember to protect strings from RCS keyword substitution)
55 #
56 $LAST_FILE = "/tmp/#cvs.lastdir"; # must match name in log_accum.pl
57
58 #
59 # Subroutines
60 #
61
62 sub write_line {
63 local($filename, $line) = @_;
64
65 open(FILE, ">$filename") || die("Cannot open $filename, stopped");
66 print(FILE $line, "\n");
67 close(FILE);
68 }
69
70 sub check_conflicts {
71 local($directory, $filename) = @_;
72
73 if (open(FILE, "<$filename")) {
74 while (<FILE>) {
75 if (/^<<<<<<<$/ || /^>>>>>>>$/) {
76 print $directory . "/" . $filename . ":\n";
77 print " This file contains unresolved merge conflicts.\n";
78 return(1);
79 }
80 }
81 }
82 close(FILE);
83 return(0);
84 }
85
86 #
87 # Main Body
88 #
89
90 $id = getpgrp(); # You *must* use a shell that does setpgrp()!
91
92 # Record the directory for later use by the log_accumulate stript.
93 #
94 $record_directory = 0;
95
96 # Get the root of the CVS tree.
97 #
98 $cvsroot = $ENV{'CVSROOT'};
99 #printf "root = " . $cvsroot . "\n";
100
101 # parse command line arguments
102 #
103 while (@ARGV) {
104 $arg = shift @ARGV;
105
106 if ($arg eq '-d') {
107 $debug = 1;
108 print STDERR "Debug turned on...\n";
109 } elsif ($arg eq '-c') {
110 $check_conflicts = 1;
111 } elsif ($arg eq '-r') {
112 $record_directory = 1;
113 } else {
114 push(@files, split(' ', $arg));
115 }
116 }
117
118 $directory = shift @files;
119 $directory =~ s,$cvsroot/,,;
120
121 if ($debug != 0) {
122 print STDERR "dir - ", $directory, "\n";
123 print STDERR "files - ", join(":", @files), "\n";
124 print STDERR "id - ", $id, "\n";
125 }
126
127 # Now check each file name passed in for unresolved merge conflicts.
128 #
129 if ($check_conflicts != 0) {
130 $failed = 0;
131 foreach $filename (@files) {
132 $failed += &check_conflicts($directory, $filename);
133 }
134 if ($failed != 0) {
135 exit(1);
136 }
137 }
138
139 # Record this directory as the last one checked. This will be used
140 # by the log_accumulate script to determine when it is processing
141 # the final directory of a multi-directory commit.
142 #
143 if ($record_directory != 0) {
144 &write_line("$LAST_FILE.$id", $directory);
145 }
146
147 exit(0);

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26