#!/bin/sh
# This script can only work truly well if the directories that have ever been in
# dirs.mk stay available.  Also, the format of dirs.mk should not change, or
# else this script will not work.
#
# This file looks in RCS/OLD as well as RCS - people should put retired
# versions of files into RCS/OLD or this script won't work.
#
# Usage: rellist <release_symbolic_name>
#

master=/a/postgres/ctree

#
# The default should be the last release
#

cd $master

if (test ! -z "$1")
then
    rel_symname=$1
else
    rel_symname=Version_2_1
fi

sedcmd="s/.*$rel_symname: //"

# 
# 
# 

echo $sedcmd

revision=`rlog -h newconf/dirs.mk|grep '^symbolic' \
         | sed "$sedcmd" | sed 's/;.*//'`

#
# If this test is true, the above sed's failed to find the given
# release name in the symbolic name list of dirs.mk
#

if (test ! -z "`echo $revision | grep symbolic`")
then
    echo "$0: $rel_symname is not a valid release - no dirs.mk" >&2
    exit 1
fi

for i in `co -s -p$revision newconf/dirs.mk`
do
    if (test -s src/$i/RCS)
    then
        if (test -d src/$i/RCS/OLD)
        then
            for j in src/$i/RCS/OLD/*,v
            do
                revision=`rlog -h $j | grep '^symbolic' \
                        | sed "$sedcmd" | sed 's/;.*//'`
                if (test ! -z "$revision")
                then
                    true_filename=`echo $j | \
                                   sed 's/RCS\/OLD.*//'``basename $j ,v`
                    echo "file $true_filename - revision $revision"
                fi
            done
        fi
        for j in src/$i/RCS/*,v
        do
            revision=`rlog -h $j | grep '^symbolic' \
                    | sed "$sedcmd" | sed 's/;.*//'`
            if (test ! -z "$revision")
            then
                true_filename=`echo $j | sed 's/RCS.*//'``basename $j ,v`
                echo "file $true_filename - revision $revision"
            fi
        done
    fi
done
