2013-04-02 Catherine Moore <clm@codesourcery.com>
[official-gcc.git] / contrib / reghunt / bin / gcc-svn-ids
blob2953e56da75c3a83bee9ecebd96109cac11faf49
1 #! /bin/sh
3 # Convert one kind of changeset identifier to another.
5 # Usage: gcc-svn-ids -f from_kind -t to_kind id
7 # Where from_kind is one of:
8 # index index into the changeset list used by the reghunt tools
9 # rev is the Subversion revision name
10 # and to_kind is one of:
11 # index index into the changeset list used by the reghunt tools
12 # rev is the Subversion revision name
13 # date expanded UTC date string
14 # branch the branch, or "trunk" for mainline
15 # author the person who checked in the patch
17 errmsg () {
18 echo $1 1>&2
21 usage () {
22 echo 'cvs_ids -f kind -t kind id' 1>&2
23 echo ' where from_kind is index or rev' 1>&2
24 echo ' and to_kind is index, rev, date, author, or branch' 1>&2
25 echo "error"
26 exit 1
29 if [ "x${REG_CHANGESET_LIST}" = "x" ]; then
30 errmsg "REG_CHANGESET_LIST is not defined"
31 echo "error"
32 exit 1
35 if [ ! -f ${REG_CHANGESET_LIST} ]; then
36 errmsg "changeset list ${REG_CHANGESET_LIST} does not exist"
37 echo "error"
38 exit 1
41 # Use a shorter name here.
42 LIST=${REG_CHANGESET_LIST}
44 while getopts "f:t:" ARG; do
45 case ${ARG} in
46 f) FROM_KIND="${OPTARG}";;
47 t) TO_KIND="${OPTARG}";;
48 h) usage;;
49 *) errmsg "unrecognized option: ${ARG}";
50 usage;;
51 esac
52 done
53 shift `expr ${OPTIND} - 1`
55 if [ $# -eq 0 ]; then
56 errmsg "too few arguments, ID is missing"
57 usage
59 if [ $# -gt 1 ]; then
60 errmsg "unexpected arguments: $*"
61 usage
63 ID="$1"
65 case ${FROM_KIND} in
66 index) LINE=`awk -F '|' -v id="${ID}" '{if ($1 == id) print }' < ${LIST}`;;
67 rev) LINE=`awk -F '|' -v id="${ID}" '{if ($2 == id) print }' < ${LIST}`;;
68 *) errmsg "unrecognized FROM kind: ${FROM_KIND}";
69 usage;;
70 esac
72 if [ "x${LINE}" = "x" ]; then
73 errmsg "no entry found for ${FROM_KIND} = ${ID}"
74 echo "error"
75 exit 1
78 case ${TO_KIND} in
79 index) TO_ID="`echo ${LINE} | awk -F '|' '{ print $1 }'`";;
80 rev) TO_ID="`echo ${LINE} | awk -F '|' '{ print $2 }'`";;
81 author) TO_ID="`echo ${LINE} | awk -F '|' '{ print $3 }'`";;
82 date) TO_ID="`echo ${LINE} | awk -F '|' '{ print $4 }'`";;
83 branch) TO_ID="`echo ${LINE} | awk -F '|' '{ print $5 }'`";;
84 *) errmsg "unrecognized TO kind: ${TO_KIND}";
85 usage;;
86 esac
88 echo ${TO_ID}