I want to get tla to write the archive and revision of the file into the file on commit in a similar way that cvs does with the $Id$ feature. I have a vague idea that this should be possible using a hook. Any ideas. Do hook occur prior or post the commit?
So far I have
tla-hook-cvs-ids
Code:
#!/bin/bash
ACTION=$1
case $ACTION in
commit)
tla-cvs-ids
VER="$ARCH_ARCHIVE $ARCH_CATEGORY--$ARCH_BRANCH--$ARCH_VERSION--$ARCH_REVISION"
find . -exec tla-cvs-id {} "$VER" \;
;;
esac
tla-cvs-id
Code:
#! /bin/bash
usage="$0 filename ?version?
This will replace \$Id\$ with the tla version and branch
"
if [ $# = 0 ]; then
echo $usage > /dev/stderr
exit 1
fi
FILE=$1
VER=$2
TMP=/tmp/tla-cvs-ids.$$
rm -Rf $TMP
mkdir $TMP
tla file-find $FILE > $TMP/tla-file-find
#./L/++pristine-trees/unlocked/C/C--B/C--B--V/A/C--B--V--P/N
if [ "$VER" == "" ]; then
# get the version
VER=`sed 's/.\/[^\/]*\/[^\/]*\/[^\/]*\/[^\/]*\/[^\/]*\/[^\/]*\/\([^\/]*\)\/\([^\/]*\)\/.*/\1 \2/' $TMP/tla-file-find`
fi
echo $VER
# get the tail of the file name
echo $FILE > $TMP/filename
FILETAIL=`sed 's/^.*\/\(.*\)$/\1/' $TMP/filename`
# generate the sed to replace the information
SED="s/\\\$Id[^\$]*\\\$/\\\$Id tla $VER $FILETAIL \\\$/"
cp $FILE $TMP/filecontent
# replace the id with the current one
sed "$SED" $TMP/filecontent > $TMP/newfilecontent
# copy the new file into place
cp $TMP/newfilecontent $FILE
# remove temp
rm -R $TMP