Mergemaster+RCS

Michael R. Wayne wayne at staff.msen.com
Mon Jan 12 23:46:25 PST 2004


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 at 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 at FreeBSD.org
  
+ # Automated support for RCS log files added 2004 by wayne at 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 at 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 at msen.com
+ 
    install -m "${1}" "${2}" "${3}" &&
    rm -f "${2}"
+ 
+   # Begin part 2 of 2 support for RCS added by wayne at 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 at msen.com
+ 
  }
  
  find_mode () {


More information about the freebsd-hackers mailing list