# Illustrate the vc hg-evolve problem.
# Needs evolve.py present in same directory.

set -x

# Settings.
repo=repo
file=$repo/readme.txt
hg="hg -R $repo"

# Initialise repo.
rm -rf $repo
hg init $repo

# Enable required extensions.
cat > $repo/.hg/hgrc <<EOF
[extensions]
evolve=evolve.py
graphlog=
EOF

# Create initial content.
cat > $file <<EOF
Hello, world!
EOF

$hg add $file
$hg ci -m "Birth."

# Add a changeset.
cat >> $file <<EOF
World, you are pretty
EOF

$hg ci -m "Life."

# Amend it.
cat >> $file <<EOF
Goodbye, world!
EOF

$hg ci -m "Death." --amend

# See where we are, with and without hidden revs.
$hg glog
$hg --hidden glog

# Get the tip revision.
tip=`$hg id -n -r tip`

# Print previous rev number, and get a failure without the '--hidden'
# option.  But even with that option, it's the Wrong Thing -- the hidden
# revs are purely internal, and should be ignored.
$hg id -n -r `expr $tip - 1`

# Print previous non-hidden parent.  This works, and is probably faster
# than using revsets.
$hg id -n -r $tip^

# But without the evolve extension enabled, we get the annoying warning
# message printed to stderr.
$hg --config extensions.evolve=! id -n -r $tip^
