pretxncommit hook destroys mq state
Weijun Max Wang
Weijun.Wang at Sun.COM
Wed Feb 13 22:36:59 CST 2008
# Run this script in an empty directory
hg init
# Create a hook that rejects any file with BAD inside it
echo '[hooks]' >> .hg/hgrc
echo 'pretxncommit = .hg/pre' >> .hg/hgrc
# The hook script
cat > .hg/pre << EOF
#! /bin/bash
FILES=\$(hg log -r \$HG_NODE: --template '{files} ')
for FILE in \$FILES; do
grep BAD \$FILE && { echo "Do not use BAD"; exit 1; }
done
exit 0
EOF
chmod a+x .hg/pre
echo GOOD > 1
hg commit -A -m Initial
hg qinit
hg qnew a
# Create a bad file
echo BAD > 2
hg add
# The next qrefresh should fail because of the bad file
hg qrefresh
# Fix it
echo GOOD > 2
# The next qrefresh should succeed
hg qrefresh
# However, it fails because the first qrefresh fails into an
# illegal state. The second part of the "rollback+commit" actions
# are rejected, but the first part remains.
#
More information about the Mercurial
mailing list