head     1.2;
branch   ;
access   ;
symbols  ;
locks    kemnitz:1.2; strict;
comment  @# @;


1.2
date     91.09.16.18.54.20;  author kemnitz;  state Exp;
branches ;
next     1.1;

1.1
date     91.09.16.02.16.15;  author kemnitz;  state Exp;
branches ;
next     ;


desc
@Unlocks the Postgres tree.
@


1.2
log
@lots of fixes
@
text
@#!/bin/sh
#
# $Header: RCS/unlocktree,v 1.1 91/09/16 02:16:15 kemnitz Exp Locker: kemnitz $
#
# Usage: unlocktree [-f]
#
# Unlocks the Postgres source tree.  This script will also create a checkin
# file, which is useful for mailing out to the post_hackers.  It also updates
# the checkin log.
#
# When used with the "-f" option, unlocktree will break another user's tree
# lock.  The lock breaker will be prompted for mail to explain why the tree
# lock was broken.
# 

MASTER=/a/postgres/ctree
LOCKFILE=$MASTER/lockfile
LOGFILE=$MASTER/logfile

if (test -r "$LOCKFILE")
then
    STATLOCK=`ls -l $LOCKFILE`
    U=`echo $STATLOCK | awk '{print $3}'`

    if (test "$1" = "-f")
    then

        #
        # just ignore "-f" flag if I've already locked the tree
        # 

        if (test "$U" != "$USER")
        then 
            echo "$U has the tree locked."

            #
            # see if there are any checked in files in the logfile
            #

            echo "Enter reason for breaking $U's tree lock"
            echo "Enter a '.' when done."

            echo "Subject: broken tree lock" >> /tmp/break$$

            r=""
            while (test "$r" != ".")
            do
                read r
                echo $r >> /tmp/break$$
            done

            mail $U < /tmp/break$$
            rm /tmp/break$$

            if (test -s $LOCKFILE)
            then
                p=`pcommit $LOGFILE $LOCKFILE $U`
                echo "Checked in files are $p"
            else
                rm -f $LOCKFILE
                echo "Tree is now unlocked."
            fi
        fi
    fi

    if (test "$U" != "$USER")
        echo "$U has the tree locked." 
        exit 1
    fi

    if (test -s $LOCKFILE)
    then
        res=""
        echo "Enter reason for checkin - type a dot when done"
        echo ==== >> $LOCKFILE
        while (test "$res" != ".")
        do
            echo -n ">> "
            read res
            echo "$res" >> $LOCKFILE
        done

        p=`pcommit $LOGFILE $LOCKFILE $U`
        echo "Checked in files are in $p"
    else
        rm -f $LOCKFILE
        echo "Tree is now unlocked."
    fi
else 
    echo "The tree is not locked."
fi
@


1.1
log
@Initial revision
@
text
@d3 1
a3 1
# $Header: RCS/locktree,v 1.1 91/09/16 01:57:42 kemnitz Exp $
d7 3
a9 3
# Unlocks the Postgres source tree.  If the same user locks the tree
# as unlocks it, then this file creates a checkin file (useful for mailing
# out to the post_hackers) and updates the checkin log.
d11 3
a13 3
# When used with the "-f" option, unlocktree will outdate checkins and
# have the user send mail to the tree locker explaining why the lock was
# broken.
a39 13
            if (test ! -s $LOGFILE)
            then
                yn=""
                while (test "$yn" != y -o "$yn" != n)
                do
                    echo -n "Would you like to back out $U's checkins (y/n) ? "
                    read yn
                done
                case $yn in
                    y) backout -f;;
                    n) echo "$0: quitting"; exit 1;;
                esac
            fi
a53 1
            rm -f $LOGFILE
d55 8
a62 8
			if (test ! -f $LOCKFILE)
			then
                echo "Tree is now unlocked"
                exit 0
			else
				echo "Tree is still locked by $U"
				exit 1
			fi
d66 1
a66 5
    if (test "$U" = "$USER")
    then
        mv $LOCKFILE /tmp/checkins.$USER
        echo "Checked in files are in /tmp/checkins.$USER"
    else
a69 1
    res=""
d71 11
a81 1
    cat /tmp/checkins.$USER >> $LOGFILE
d83 6
a88 8
    echo "Enter reason for checkin - type a dot when done"
    while (test "$res" != ".")
    do
        echo -n ">> "
        read res
        echo "$res" >> /tmp/checkins.$USER
        echo "$res" >> $LOGFILE
    done
@
