#!/bin/sh

echo "[extensions]" >> $HGRCPATH
echo "graphlog=" >> $HGRCPATH
echo "mq=" >> $HGRCPATH

hg init test
cd test
echo 'A'>a
hg ci -A -d '0 0' -m 'A'

echo 'B'>b
hg add b
hg qnew -f -d '1 0' p1.patch -m 'B'

echo
echo '% Trying to commit over an mq patch (not allowed)'
echo 'D'>d
hg ci -A -d '3 0' -m 'D'
hg forget d
rm d

echo 'C'>c
hg add c
hg qnew -f -d '2 0' p2.patch -m 'C'
hg glog  --template '{rev}: {desc} tags: {tags}\n'

echo
echo '% But we can obtain a revision as child of an mq patch if we pull'
cd ../
hg clone test test2 -r 0
cd test2
echo 'B'>b
hg add b
hg ci -A -d '1 0' -m 'B'

echo 'D'>d
hg ci -A -d '2 0' -m 'D'
hg glog  --template '{rev}: {desc} tags: {tags}\n'

cd ../test
hg pull ../test2
hg glog  --template '{rev}: {desc} tags: {tags}\n'

echo '% Qfinish rev2 will fail'
hg qfinish 2

echo
echo '% We have to finalize rev1 first and then rev2'
hg qfinish 1
hg qfinish 2
hg glog  --template '{rev}: {desc} tags: {tags}\n'

