#!/bin/sh
# Name : /public/scripts/cico
# Purpose : check-out after checkin script
# Arguments : 1- A given submitted changelist number.
# By : Yariv Sheizaf
# Date : 26.11.2001
echo ""
echo "Submitted changelist number ?"
echo ""
read ANS
CHG=$ANS
p4 change -o $CHG 1>/dev/null 2>&1
if [ "$?" != "0" ]
then
echo ""
echo "Changelist No. "$CHG" is not exist. Exit..."
echo ""
exit 1
fi
ISSUBMITTED=`p4 describe $CHG | /usr/bin/head -1 | awk '{print $NF}'`
if [ "$ISSUBMITTED" = "*pending*" ]
then
echo ""
echo "Changelist No. "$CHG" is still pending. Exit..."
echo ""
exit 1
fi
## Create new pending changelist
p4 change -o $CHG | sed 's/'$CHG'/new/' | p4 change -i > $$.newchg
if [ "$?" != "0" ]
then
echo ""
echo "The source changelist "$CHG" is not owned by this user. Exit..."
echo ""
exit 1
fi
NEWCHG=`awk '{print $2}' $$.newchg`
p4 describe -s $CHG | grep "^... //" | awk -F# '{print $1}' | sed 's/... //' | sed 's/ /@@@/g' > $$.flist
for i in `cat $$.flist`
do
SRCFILE=`echo $i | sed 's/@@@/ /g'`
p4 sync "$SRCFILE"
p4 edit -c $NEWCHG "$SRCFILE"
done
rm -f $$.*
echo ""
echo "Press any key to exit"
echo ""
read ANS
exit 0