#!/bin/sh
# Name : /public/scripts/bydirinteg
# Purpose : Integrate from one directories tree to another according to
# a given submitted changelist number (Z2H <-> Z2H_epop)
# By : Yariv Sheizaf
# Date : 13.9.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
NEWCHG=`awk '{print $2}' $$.newchg`
SRCDIR=`p4 describe -s $CHG | grep "^... //" | awk -F# '{print $1}' | sed 's/... //' | awk -F/ '{print $6}' | sort | uniq`
if [ "$SRCDIR" = "Z2H" ]
then
TRGDIR="Z2H_epop"
else
if [ "$SRCDIR" = "Z2H_epop" ]
then
TRGDIR="Z2H"
else
echo ""
echo $SRCDIR" is not relevant for "$0" running"
echo ""
exit 1
fi
fi
p4 describe -s $CHG | grep "^... //" | awk -F# '{print $1}' | sed 's/... //' | sed 's/ /@@@/g' > $$.flist
IS1CNF=`awk -F/ '{print $4}' $$.flist | sort | uniq | wc -l | awk '{print $1}'`
if [ "$IS1CNF" != "1" ]
then
echo ""
echo "There are more than one source configuration in changelist No. "$CHG
echo ""
exit 1
fi
for i in `cat $$.flist`
do
SRCFILE=`echo $i | sed 's/@@@/ /g'`
ISDSP=`echo $SRCFILE | awk -F. '{print $NF}'`
if [ "$ISDSP" != "dsp" -a "$ISDSP" != "dsw" ]
then
TRGFILE=`echo $SRCFILE | sed 's/'$SRCDIR'/'$TRGDIR'/'`
p4 integrate -c $NEWCHG -f -d -i -v "$SRCFILE" "$TRGFILE"
p4 resolve -at -af "$TRGFILE"
fi
done
p4 submit -c $NEWCHG
rm -f $$.*
echo ""
echo "Press any key to exit"
echo ""
read ANS
exit 0