#!/usr/bin/perl # # This program is intended to be run by the end user to record that # he or she is editing a file. It is intended for use within # development processes that forbid concurrent development. It # first issues a "cvs editors" command, then if that returns # nothing issues a "cvs edit" command. This is not perfect, in # that if two people issue this at the same time they may both # be given edit status. # # This program takes zero arguments, meaning the whole directory, # or more than one argument, meaning listed files. # #Copyright 2002, David H. Thornley. #Permission granted to use under Gnu General Public License, version 2 or later. #This license is available at http://www.thornleyweb.com/perl/license.html #No warranty, express or implied, except by separate agreement. my ($file_name_list) = ""; my ($file_name) = ""; my ($edit_line); while ($file_name = shift) { $file_name_list += "$file_name "; } my (@editors) = `cvs editors $file_name_list`; if (@editors) { print "Edit failed due to pre-existing edits:\n"; foreach $edit_line (@editors) { print "$edit_line\n"; } } else { `cvs edit $file_name_list`; } # check for simultaneous edit my ($abort_flag) = 0; foreach $file_name ($file_name_list) { my (@editors) = `cvs editors $file_name`; if (@editors > 1) { print "Edit failed due to simultaneous edits:\n"; $abort_flag = 1; foreach $edit_line (@editors) { print "$edit_line\n"; } } } if ($abort_flag) { `cvs unedit $file_name_list` }