tests/test-keyword
author Christian Ebert <blacktrash@gmx.net>
Thu, 26 Jul 2007 18:24:35 +0200
changeset 216 f35a0c382168
parent 215 ff719fcc10a3
child 218 d7ddb4e378f3
permissions -rwxr-xr-x
Stricter regex; regroup kwtemplater init code

#!/bin/sh

cat <<EOF >> $HGRCPATH
[extensions]
hgext.keyword =
[keyword]
* =
b = ignore
EOF

echo % help
# sed for backwards compatibility
hg help keyword \
| sed -e '/^list of commands/d' -e '/hg -v help keyword/d' -e '/^$/d'

echo % hg kwdemo
hg --quiet kwdemo --default \
| sed -e 's![^ ][^ ]*demo.txt,v!/TMP/demo.txt,v!' \
 -e 's/,v [a-z0-9][a-z0-9]* /,v xxxxxxxxxxxx /' \
 -e '/[$]Revision/ s/: [a-z0-9][a-z0-9]* /: xxxxxxxxxxxx /' \
 -e 's! 20[0-9][0-9]/[01][0-9]/[0-3][0-9] [0-2][0-9]:[0-6][0-9]:[0-6][0-9]! 2000/00/00 00:00:00!'

hg --quiet kwdemo "Branch = {branches}"

hg init Test
cd Test

echo % kwshrink should abort in empty/invalid repo
hg kwshrink

echo 'expand $Id$' > a
echo 'ignore $Id$' > b
echo % cat
cat a b

echo % default keyword expansion
echo % commit
hg --debug commit -A -mab -d '0 0' -u 'User Name <user@example.com>'
echo % status
hg status
echo % identify
hg --quiet identify
echo % cat
cat a b
echo % hg cat
hg cat a b

echo % touch
touch a b
echo % status
hg status

rm a b
echo % update
hg update
echo % cat
cat a b

echo % copy
hg cp a c
echo % commit
hg --debug commit -ma2c -d '1 0' -u 'User Name <user@example.com>'
echo % cat a c
cat a c
echo % touch copied c
touch c
echo % status
hg status

echo % rollback
hg rollback
echo % status
hg status
echo % update -C
hg update --clean

echo % custom keyword expansion
echo % try with kwdemo
hg --quiet kwdemo "Xinfo = {author}: {desc}"

cat <<EOF >>$HGRCPATH
[keywordmaps]
Id = {file} {node|short} {date|rfc822date} {author|user}
Xinfo = {author}: {desc}
EOF

echo % cat
cat a b
echo % hg cat
hg cat a b

echo '$Xinfo$' >> a
cat <<EOF >> log
firstline
secondline
EOF

echo % interrupted commit
# redirection and sed for backwards compatibility
HGEDITOR=false hg commit 2>&1 | sed -e '/edit failed:/d'
echo % status
hg status

echo % commit
hg --debug commit -l log -d '2 0' -u 'User Name <user@example.com>'
rm log
echo % status
hg status

echo % cat
cat a b
echo % hg cat
hg cat a b

echo % remove
hg remove a
hg --debug commit -m rma
echo % status
hg status
echo % rollback
hg rollback
echo % status
hg status
echo % revert a
hg revert --no-backup --rev tip a
echo % cat a
cat a

echo % clone to test incoming
cd ..
hg clone -r0 Test Test-a
cd Test-a
cat <<EOF >> .hg/hgrc
[paths]
default = ../Test
EOF
echo % incoming
# remove path to temp dir for backwards compatibility
hg incoming | sed -e '/^comparing with/d'

echo % switch off expansion
cd ../Test
echo % kwshrink
hg --debug kwshrink
echo % cat
cat a b
echo % hg cat
hg cat a b

rm $HGRCPATH
echo % cat
cat a b
echo % hg cat
hg cat a b