Here is a patch to commit_prep2 to check conflicts and prevent commiting conflicts. I don't dare to commit this myself, so if someone wants to verify this is correct and commit_prep2 really works after patching, (s)he can commit this one. After committing also add "-c" parameter to commit_prep2 in commitinfo so it really checks for conflicts too.
Index: commit_prep2 =================================================================== RCS file: /cvs/webwml/CVSROOT/commit_prep2,v retrieving revision 1.2 diff -u -r1.2 commit_prep2 --- commit_prep2 2001/04/08 17:16:25 1.2 +++ commit_prep2 2001/05/29 18:46:42 @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#! /usr/bin/perl # -*-Perl-*- # #ident "@(#)cvs/contrib:$Name: $:$Id: commit_prep2,v 1.2 2001/04/08 17:16:25 joey Exp $" @@ -9,20 +9,19 @@ # existence of a RCS "Id" keyword in the first ten lines of the file. # For existing files, it checks version number in the "Id" line to # prevent losing changes because an old version of a file was copied -# into the direcory. +# into the direcory. Also check for unresolved merge conflicts. # # Possible future enhancements: # -# Check for cruft left by unresolved conflicts. Search for -# "^<<<<<<<$", "^-------$", and "^>>>>>>>$". -# # Look for a copyright and automagically update it to the # current year. [[ bad idea! -- woods ]] # # # Contributed by David Hampton <[EMAIL PROTECTED]> -# # Hacked on lots by Greg A. Woods <[EMAIL PROTECTED]> +# Conflict check by Charles M. Hannum <[EMAIL PROTECTED]> +# Merged Hannum's conflict checks with RCS Id checking by Tommi +# Vainikainen <[EMAIL PROTECTED]> # # Configurable options @@ -77,6 +76,22 @@ close(FILE); } +sub check_conflicts { + local($directory, $filename) = @_; + + if (open(FILE, "<$filename")) { + while (<FILE>) { + if (/^<<<<<<<$/ || /^>>>>>>>$/) { + print $directory . "/" . $filename . ":\n"; + print " This file contains unresolved merge conflicts.\n"; + return(1); + } + } + } + close(FILE); + return(0); +} + sub check_version { local($i, $id, $rname, $version); local($filename, $cvsversion) = @_; @@ -148,6 +163,10 @@ $id = getpgrp(); # You *must* use a shell that does setpgrp()! +# Check each file (except dot files) +# +$check_conflicts = 0; + # Check each file (except dot files) for an RCS "Id" keyword. # $check_id = 0; @@ -165,11 +184,13 @@ $debug = 1; print STDERR "Debug turned on...\n"; } elsif ($arg eq '-c') { + $check_conflicts = 1; + } elsif ($arg eq '-i') { $check_id = 1; } elsif ($arg eq '-r') { $record_directory = 1; } else { - push(@files, $arg); + push(@files, split(' ', $arg)); } } @@ -181,6 +202,16 @@ print STDERR "id - ", $id, "\n"; } +$failed = 0; + +# Now check each file name passed in for unresolved merge conflicts. +# +if ($check_conflicts != 0) { + foreach $filename (@files) { + $failed += &check_conflicts($directory, $filename); + } +} + # Suck in the CVS/Entries file # open(ENTRIES, $ENTRIES) || die("Cannot open $ENTRIES.\n"); @@ -193,17 +224,17 @@ # are considered to be administrative files by this script. # if ($check_id != 0) { - $failed = 0; foreach $arg (@files) { if (index($arg, ".") == 0) { next; } $failed += &check_version($arg); - } - if ($failed) { - print STDERR "\n"; - exit(1); } +} + +if ($failed) { + print STDERR "\n"; + exit(1); } # Record this directory as the last one checked. This will be used
-- Tommi Vainikainen