From owner-freebsd-hackers@FreeBSD.ORG Mon Jan 12 23:46:25 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AE4BC16A4CE for ; Mon, 12 Jan 2004 23:46:25 -0800 (PST) Received: from manor.msen.com (manor.msen.com [148.59.4.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id D949643D2F for ; Mon, 12 Jan 2004 23:46:23 -0800 (PST) (envelope-from wayne@staff.msen.com) Received: from manor.msen.com (wayne@localhost [127.0.0.1]) by manor.msen.com (8.12.7M/8.12.7) with ESMTP id i0D7kNEk004375 for ; Tue, 13 Jan 2004 02:46:23 -0500 (EST) Message-Id: <200401130746.i0D7kNEk004375@manor.msen.com> To: hackers@freebsd.org Date: Tue, 13 Jan 2004 02:46:23 -0500 From: "Michael R. Wayne" Subject: Mergemaster+RCS X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jan 2004 07:46:25 -0000 Although Doug Barton has written a wonderful tool, it has always seemed to have a major deficiency: it completely ignores the existance of RCS files. I've exchanged some email with Doug and he has no interest in adding RCS support to mergemaster. So I did. Doug has mentioned that some people solve this problem by using the precompare script or by checking out all RCS files before running mergemaster then checking them in afterwards. These solutions are highly unattractive to me since they require sysadmins to remember far too much, especially given that systems are often upgraded at off hours to minimize user impact. The attached patch to the mergemaster in 4.9-RELEASE-p1 addresses this issue. Specifically, it does the following, automatically: For every file that mergemaster replaces, check for the existance of an associated RCS log file in the RCS subdirectory. (I do NOT check for the logfile in the current directory). If such a logfile exists If the file is currently checked out, check it in with an automated comment. Check the file out. Apply the upgrade. Check the file in with an automated comment. If the file was originally checked out, check it back out again. If no associated RCS log file exists, there is no change in the operation of mergemaster. I take care to leave the log file in the original checked in/out state: People have tools that "know" the state of logfiles and these tools should not be broken. This seems to work for us. Comments/suggestions welcome. /\/\ \/\/ *** /usr/sbin/mergemaster Thu Jan 8 17:03:30 2004 --- mergemaster+rcs Fri Jan 9 08:45:19 2004 *************** *** 8,20 **** # Copyright 1998-2003 Douglas Barton # DougB@FreeBSD.org # $FreeBSD: src/usr.sbin/mergemaster/mergemaster.sh,v 1.6.2.18 2003/08/25 08:27:41 dougb Exp $ PATH=/bin:/usr/bin:/usr/sbin display_usage () { VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4` ! echo "mergemaster version ${VERSION_NUMBER}" echo 'Usage: mergemaster [-scrvahipCP] [-m /path]' echo ' [-t /path] [-d] [-u N] [-w N] [-D /path]' echo "Options:" --- 8,22 ---- # Copyright 1998-2003 Douglas Barton # DougB@FreeBSD.org + # Automated support for RCS log files added 2004 by wayne@msen.com + # $FreeBSD: src/usr.sbin/mergemaster/mergemaster.sh,v 1.6.2.18 2003/08/25 08:27:41 dougb Exp $ PATH=/bin:/usr/bin:/usr/sbin display_usage () { VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4` ! echo "mergemaster version ${VERSION_NUMBER} with RCS support" echo 'Usage: mergemaster [-scrvahipCP] [-m /path]' echo ' [-t /path] [-d] [-u N] [-w N] [-D /path]' echo "Options:" *************** *** 646,653 **** --- 648,695 ---- ;; esac + # Begin part 1 of 2 support for RCS added by wayne@msen.com + # Deals with RCS log files in the RCS subdirectory, first checking + # in previous changes (if any), checks in the changes made by + # mergemaster and leaves the file in the original checked in/out state. + # + # Assume we will not need to check this file in. + local MM_RCS + MM_RCS=0 + if [ -d ${3}/RCS ]; then + # The RCS directory exists, check it for this logfile + if [ -e ${3}/RCS/${2##*/},v ]; then + # The RCS logfile exists, now we need to know it's existing state + if [ -z `rlog -L -R ${3}/${2##*/}` ]; then + # Target file is unlocked, check it out + co -l ${3}/${2##*/} + # Remember to leave file unlocked after install + MM_RCS=1 + else + # File is already locked, check it in before we mess with it + ci -l -m"Mergemaster auto checkin of locked file." ${3}/${2##*/} + # Remember to leave file locked after install + MM_RCS=2 + fi + fi + fi + # End part 1 of 2 support for RCS added by wayne@msen.com + install -m "${1}" "${2}" "${3}" && rm -f "${2}" + + # Begin part 2 of 2 support for RCS added by wayne@msen.com + if [ $MM_RCS -eq 1 ]; then + # Checkin the file, leaving it unlocked + ci -u -m"Mergemaster auto checkin after updates" ${3}/${2##*/} + elif [ $MM_RCS -eq 2 ]; then + # Checkin the file, leaving it locked + ci -l -m"Mergemaster auto checkin after updates" ${3}/${2##*/} + else + # Do nothing, no RCS log file exists + fi + # End part 2 of 2 support for RCS added by wayne@msen.com + } find_mode () {