tests/test-keyword
author Christian Ebert <blacktrash@gmx.net>
Fri, 22 Aug 2008 11:53:30 +0200
branch0.9.2compat
changeset 486 a6f4e1367978
parent 483 ad766066d1bc
child 489 f3514954d3c6
permissions -rwxr-xr-x
(0.9.2compat) add merge, resolve to restricted This is not really backwards compatible (test only as comment) and doesn't prevent extra conflicts with older Hg versions. On the other hand it doesn't do any damage either and provides the 3-way merge ease if possible.

#!/bin/sh

cat <<EOF >> $HGRCPATH
[extensions]
hgext.keyword =
hgext.mq =
[keyword]
* =
b = ignore
[hooks]
commit=
commit.test=cp a hooktest
EOF

echo % help
# grep for backwards compatibility
hg help keyword \
| grep -E -v '^list of commands|hg -v help keyword|^$'

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-bndl
cd Test-bndl

echo % kwshrink should exit silently in empty/invalid repo
hg kwshrink

# Symlinks cannot be created on Windows. The bundle was made with:
#
# hg init t
# cd t
# echo a > a
# ln -s a sym
# hg add sym
# hg ci -m addsym -u mercurial
# hg bundle --base null ../test-keyword.hg
#
hg pull -u "$TESTDIR/test-keyword.hg" \
    | sed 's/pulling from.*test-keyword.hg/pulling from test-keyword.hg/'

echo 'expand $Id$' > a
echo 'do not process $Id:' >> a
echo 'xxx $' >> a
echo 'ignore $Id$' > b
echo % cat
cat a b

echo % addremove
hg addremove
echo % status
hg status

echo % default keyword expansion including commit hook
#echo % interrupted commit should not change state or run commit hook
#hg --debug commit
#echo % status
#hg status

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

echo
echo % diff a hooktest
diff a hooktest

echo % removing commit hook from config
sed -e '/\[hooks\]/,$ d' $HGRCPATH > $HGRCPATH.nohook
mv $HGRCPATH.nohook $HGRCPATH
rm hooktest

echo % bundle
hg --quiet bundle --base null ../kw.hg

cd ..
hg init Test
cd Test

echo % pull from bundle
hg pull -u ../kw.hg

echo % touch
touch a b
echo % status
hg status

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

echo % check whether expansion is filewise
echo '$Id$' > c
echo 'tests for different changenodes' >> c
echo % commit c
hg commit -A -mcndiff -d '1 0' -u 'User Name <user@example.com>'
echo % force expansion
hg -v kwexpand
echo % compare changenodes in a c
cat a c

echo % qinit -c
hg qinit -c
echo % qimport
hg qimport -r tip -n mqtest.diff
echo % qcommit
hg qcommit -mqtest
echo % keywords should not be expanded in patch
cat .hg/patches/mqtest.diff
echo % qpop
hg qpop
echo % qpush
hg qpush
echo % cat
cat c
echo % qpop and move on
hg qpop

echo % copy
hg cp a c

echo % kwfiles added
hg kwfiles

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 after 1 second
sleep 1
touch c
echo % status
hg status

echo % kwfiles
hg kwfiles

echo % diff --rev
hg diff --rev 1 | grep -v 'b/c'

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 should not change state
#hg commit
#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 % verify
hg verify

echo % cat
cat a b
echo % hg cat
hg cat sym a b
echo
echo % annotate
hg annotate a

echo % remove
hg debugrebuildstate
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 ..
# remove updating status for backwards compatibility
hg clone -r1 Test Test-a | grep -v 'working directory'
cd Test-a
cat <<EOF >> .hg/hgrc
[paths]
default = ../Test
EOF
echo % incoming
# remove path to temp dir for backwards compatibility
hg incoming | grep -v '^comparing with'

#sed -e 's/Id.*/& rejecttest/' a > a.new
#mv a.new a
#echo % commit rejecttest
#hg --debug commit -m'rejects?' -d '3 0' -u 'User Name <user@example.com>'
#echo % export
#hg export -o ../rejecttest.diff tip

cd ../Test
#echo % import
#hg import ../rejecttest.diff
#echo % cat
#cat a b
#echo % rollback
#hg rollback
#echo % clean update
#hg update --clean

echo % kwexpand/kwshrink on selected files
mkdir x
echo % copy a x/a
hg copy a x/a
echo % kwexpand a
hg --verbose kwexpand a
echo % kwexpand x/a should abort
hg --verbose kwexpand x/a
cd x
hg --debug commit -m xa -d '3 0' -u 'User Name <user@example.com>'
echo % cat a
cat a
echo % kwshrink a inside directory x
hg --verbose kwshrink a
echo % cat a
cat a
cd ..

echo % kwexpand nonexistent
hg kwexpand nonexistent 2>&1 | sed 's/nonexistent:.*/nonexistent:/'

#echo % hg serve
#hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
#cat hg.pid >> $DAEMON_PIDS
#echo % expansion
#echo % hgweb file
#("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/a/?style=raw')
#echo % no expansion
#echo % hgweb annotate
#("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/annotate/tip/a/?style=raw')
#echo % hgweb changeset
#("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/rev/tip/?style=raw')
#echo % hgweb filediff
#("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/bb948857c743/a?style=raw')
#echo % errors encountered
#cat errors.log

#echo % merge/resolve
#echo '$Id$' > m
#hg add m
#hg commit -m 4kw 
#echo foo >> m
#hg commit -m 5foo
#echo % simplemerge
#hg update 4
#echo foo >> m
#hg commit -m 6foo
#hg merge
#hg commit -m simplemerge
#cat m
#echo % conflict
#hg update 4
#echo bar >> m
#hg commit -m 8bar
#hg merge
#echo % keyword stays outside conflict zone
#cat m
#echo % resolve to local
#HGMERGE=internal:local hg resolve
#hg commit -m localresolve
#cat m

echo % switch off expansion
echo % kwshrink with unknown file u
cp a u
hg --verbose 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