1257313Sbapt#! /bin/sh 2257313Sbapt 3319349Sjkim# Convert one kind of changeset identifier to another. 4257313Sbapt# 5319349Sjkim# Usage: gcc-svn-ids -f from_kind -t to_kind id 6257313Sbapt# 7257313Sbapt# Where from_kind is one of: 8257313Sbapt# index index into the changeset list used by the reghunt tools 9257313Sbapt# rev is the Subversion revision name 10257313Sbapt# and to_kind is one of: 11257313Sbapt# index index into the changeset list used by the reghunt tools 12257313Sbapt# rev is the Subversion revision name 13257313Sbapt# date expanded UTC date string 14257313Sbapt# branch the branch, or "trunk" for mainline 15257313Sbapt# author the person who checked in the patch 16257313Sbapt 17257313Sbapterrmsg () { 18257313Sbapt echo $1 1>&2 19257313Sbapt} 20257313Sbapt 21257313Sbaptusage () { 22257313Sbapt echo 'cvs_ids -f kind -t kind id' 1>&2 23257313Sbapt echo ' where from_kind is index or rev' 1>&2 24257313Sbapt echo ' and to_kind is index, rev, date, author, or branch' 1>&2 25257313Sbapt echo "error" 26257313Sbapt exit 1 27257313Sbapt} 28257313Sbapt 29257313Sbaptif [ "x${REG_CHANGESET_LIST}" = "x" ]; then 30257313Sbapt errmsg "REG_CHANGESET_LIST is not defined" 31257313Sbapt echo "error" 32257313Sbapt exit 1 33257313Sbaptfi 34257313Sbapt 35257313Sbaptif [ ! -f ${REG_CHANGESET_LIST} ]; then 36257313Sbapt errmsg "changeset list ${REG_CHANGESET_LIST} does not exist" 37257313Sbapt echo "error" 38257313Sbapt exit 1 39257313Sbaptfi 40257313Sbapt 41257313Sbapt# Use a shorter name here. 42257313SbaptLIST=${REG_CHANGESET_LIST} 43257313Sbapt 44257313Sbaptwhile getopts "f:t:" ARG; do 45257313Sbapt case ${ARG} in 46257313Sbapt f) FROM_KIND="${OPTARG}";; 47257313Sbapt t) TO_KIND="${OPTARG}";; 48257313Sbapt h) usage;; 49257313Sbapt *) errmsg "unrecognized option: ${ARG}"; 50257313Sbapt usage;; 51257313Sbapt esac 52257313Sbaptdone 53257313Sbaptshift `expr ${OPTIND} - 1` 54257313Sbapt 55257313Sbaptif [ $# -eq 0 ]; then 56257313Sbapt errmsg "too few arguments, ID is missing" 57257313Sbapt usage 58257313Sbaptfi 59257313Sbaptif [ $# -gt 1 ]; then 60257313Sbapt errmsg "unexpected arguments: $*" 61 usage 62fi 63ID="$1" 64 65case ${FROM_KIND} in 66index) LINE=`awk -F '|' -v id="${ID}" '{if ($1 == id) print }' < ${LIST}`;; 67rev) LINE=`awk -F '|' -v id="${ID}" '{if ($2 == id) print }' < ${LIST}`;; 68*) errmsg "unrecognized FROM kind: ${FROM_KIND}"; 69 usage;; 70esac 71 72if [ "x${LINE}" = "x" ]; then 73 errmsg "no entry found for ${FROM_KIND} = ${ID}" 74 echo "error" 75 exit 1 76fi 77 78case ${TO_KIND} in 79index) TO_ID="`echo ${LINE} | awk -F '|' '{ print $1 }'`";; 80rev) TO_ID="`echo ${LINE} | awk -F '|' '{ print $2 }'`";; 81author) TO_ID="`echo ${LINE} | awk -F '|' '{ print $3 }'`";; 82date) TO_ID="`echo ${LINE} | awk -F '|' '{ print $4 }'`";; 83branch) TO_ID="`echo ${LINE} | awk -F '|' '{ print $5 }'`";; 84*) errmsg "unrecognized TO kind: ${TO_KIND}"; 85 usage;; 86esac 87 88echo ${TO_ID} 89