#!/bin/sh
cat <<EOF >> $HGRCPATH
[extensions]
hgext.keyword =
[keyword]
a =
b = ignore
c = archive
EOF
echo % help
hg help keyword
hg init Test
cd Test
echo 'expand $Id$' > a
echo 'ignore $Id$' > b
echo 'archive $Id$' > c
ln -s a sym
echo % cat
cat a b c sym
echo % default keyword expansion
echo % commit
hg --debug commit -A -mabcsym -d '0 0' -u 'User Name <user@example.com>'
echo % status
hg status
echo % cat
cat a b c sym
echo % hg cat
hg cat a b c sym
echo
rm a b c sym
echo % update
hg update
echo % cat
cat a b c sym
echo % archive
hg archive ../Archive
cd ../Archive
echo % cat
cat a b c sym
echo
cd -
echo % custom keyword expansion
cat <<EOF >>$HGRCPATH
[keywordmaps]
Id = {file} {node|short} {date|rfc822date} {author|user}
Xinfo = {author}: {desc}
EOF
echo % cat
cat a b c sym
echo % hg cat
hg cat a b c sym
echo
echo '$Xinfo$' >> a
cat <<EOF >> log
firstline
secondline
EOF
echo % commit
hg --debug commit -l log -d '1 0' -u 'User Name <user@example.com>'
rm log
echo % status
hg status
echo % cat
cat a b c sym
echo % hg cat
hg cat a b c sym
echo
cd ..
hg clone -r0 Test Test-a
cd Test-a
cat <<EOF >> .hg/hgrc
[paths]
default = ../Test
EOF
echo % incoming
hg incoming
echo % switch off expansion
rm $HGRCPATH
cd ../Test
echo % cat
cat a b c sym
echo % hg cat
hg cat a b c sym
echo
echo % update
rm a b c sym
hg update
echo % cat
cat a b c sym