view tests/test-tags @ 9143:a604c98dbf62

test-tags: clarify test output; simplify test script a bit (issue548). - use simpler way ('hg id') to get current changeset id - add 'echo' statements to guide the eye when reading output - add some more output to clarify the state of .hgtags - drop '-d' option from every commit/tag, since run-tests.py does this (although with a different timestamp, so changeset ids differ)
author Greg Ward <greg-hg@gerg.ca>
date Thu, 16 Jul 2009 10:39:41 -0400
parents ae3089cefaab
children ad72e3b08bc0
line wrap: on
line source

#!/bin/sh

echo "% setup"
mkdir t
cd t
hg init
hg id
echo a > a
hg add a
hg commit -m "test"
hg co
hg identify

echo "% create local tag with long name"
T=`hg identify --debug --id`
hg tag -l "This is a local tag with a really long name!"
hg tags
rm .hg/localtags

echo "% create a tag behind hg's back"
echo "$T first" > .hgtags
cat .hgtags
hg add .hgtags
hg commit -m "add tags"
hg tags
hg identify

echo "% create a branch"
echo bb > a
hg status
hg identify
hg co first
hg id
hg -v id
hg status
echo 1 > b
hg add b
hg commit -m "branch"
hg id

echo "% merge the two heads"
hg merge 1
hg id
hg status

hg commit -m "merge"

echo "% create fake head, make sure tag not visible afterwards"
cp .hgtags tags
hg tag last
hg rm .hgtags
hg commit -m "remove"

mv tags .hgtags
hg add .hgtags
hg commit -m "readd"

hg tags

echo "% add invalid tags"
echo "spam" >> .hgtags
echo >> .hgtags
echo "foo bar" >> .hgtags
echo "$T invalid" | sed "s/..../a5a5/" >> .hg/localtags
echo "committing .hgtags:"
cat .hgtags 
hg commit -m "tags"

echo "% report tag parse error on other head"
hg up 3
echo 'x y' >> .hgtags
hg commit -m "head"

hg tags
hg tip

echo "% test tag precedence rules"
cd ..
hg init t2
cd t2
echo foo > foo
hg add foo
hg ci -m 'add foo'      # rev 0
hg tag bar              # rev 1
echo >> foo
hg ci -m 'change foo 1' # rev 2
hg up -C 1
hg tag -r 1 -f bar      # rev 3
hg up -C 1
echo >> foo
hg ci -m 'change foo 2' # rev 4
hg tags

echo "% test tag removal"
hg tag --remove bar     # rev 5
hg tip -vp
hg tags

echo '% remove nonexistent tag'
hg tag --remove foobar
hg tip

echo "% test tag rank"
cd ..
hg init t3
cd t3
echo foo > foo
hg add foo
hg ci -m 'add foo'       # rev 0
hg tag -f bar            # rev 1 bar -> 0
hg tag -f bar            # rev 2 bar -> 1
hg tag -fr 0 bar         # rev 3 bar -> 0
hg tag -fr 1 bar         # rev 4 bar -> 1
hg tag -fr 0 bar         # rev 5 bar -> 0
hg tags
hg co 3
echo barbar > foo
hg ci -m 'change foo'    # rev 6
hg tags

echo "% don't allow moving tag without -f"
hg tag -r 3 bar
hg tags

echo "% test tag rank with 3 heads"
cd ..
hg init t4
cd t4
echo foo > foo
hg add
hg ci -m 'add foo'                 # rev 0
hg tag bar                         # rev 1 bar -> 0
hg tag -f bar                      # rev 2 bar -> 1
hg up -qC 0
hg tag -fr 2 bar                   # rev 3 bar -> 2
hg tags
hg up -qC 0
hg tag -m 'retag rev 0' -fr 0 bar  # rev 4 bar -> 0, but bar stays at 2
echo "% bar should still point to rev 2"
hg tags


echo "% remove local as global and global as local"
# test that removing global/local tags does not get confused when trying
# to remove a tag of type X which actually only exists as a type Y
cd ..
hg init t5
cd t5
echo foo > foo
hg add
hg ci -m 'add foo'                 # rev 0

hg tag -r 0 -l localtag
hg tag --remove localtag

hg tag -r 0 globaltag
hg tag --remove -l globaltag
hg tags -v
exit 0