##// END OF EJS Templates
Merge with i18n
Merge with i18n

File last commit:

r9014:87c05a78 default
r9850:004bf1d6 merge default
Show More
test-hook
251 lines | 6.3 KiB | text/plain | TextLexer
Thomas Arendsen Hein
Don't use 'set -x', fix exports, sed and hexdump usage for Solaris.
r800 #!/bin/sh
mpm@selenic.com
Add initial hook support...
r487
Alexis S. L. Carvalho
test-hook: use printenv.py
r4286 cp "$TESTDIR"/printenv.py .
Vadim Gelfer
tests for new hooks. fix things i found when writing tests.
r1734 # commit hooks can see env vars
hg init a
cd a
mpm@selenic.com
Add initial hook support...
r487 echo "[hooks]" > .hg/hgrc
Thomas Arendsen Hein
Work around problem where 'del os.environ["FOO"]' doesn't update environment....
r4368 echo 'commit = unset HG_LOCAL HG_TAG; python ../printenv.py commit' >> .hg/hgrc
echo 'commit.b = unset HG_LOCAL HG_TAG; python ../printenv.py commit.b' >> .hg/hgrc
echo 'precommit = unset HG_LOCAL HG_NODE HG_TAG; python ../printenv.py precommit' >> .hg/hgrc
echo 'pretxncommit = unset HG_LOCAL HG_TAG; python ../printenv.py pretxncommit' >> .hg/hgrc
Alexis S. L. Carvalho
test-hook: use printenv.py
r4286 echo 'pretxncommit.tip = hg -q tip' >> .hg/hgrc
Thomas Arendsen Hein
Use printenv.py for pre/post-command-hooks (fixes tests on Solaris, too)
r4634 echo 'pre-identify = python ../printenv.py pre-identify 1' >> .hg/hgrc
echo 'pre-cat = python ../printenv.py pre-cat' >> .hg/hgrc
echo 'post-cat = python ../printenv.py post-cat' >> .hg/hgrc
mpm@selenic.com
Add initial hook support...
r487 echo a > a
hg add a
Thomas Arendsen Hein
Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero....
r1933 hg commit -m a -d "1000000 0"
Vadim Gelfer
tests for new hooks. fix things i found when writing tests.
r1734
hg clone . ../b
cd ../b
# changegroup hooks can see env vars
echo '[hooks]' > .hg/hgrc
Alexis S. L. Carvalho
test-hook: use printenv.py
r4286 echo 'prechangegroup = python ../printenv.py prechangegroup' >> .hg/hgrc
echo 'changegroup = python ../printenv.py changegroup' >> .hg/hgrc
echo 'incoming = python ../printenv.py incoming' >> .hg/hgrc
Vadim Gelfer
tests for new hooks. fix things i found when writing tests.
r1734
# pretxncommit and commit hooks can see both parents of merge
cd ../a
echo b >> a
hg commit -m a1 -d "1 0"
hg update -C 0
echo b > b
hg add b
hg commit -m b -d '1 0'
Vadim Gelfer
deprecate 'update -m'. use 'merge' instead.
r2283 hg merge 1
Vadim Gelfer
tests for new hooks. fix things i found when writing tests.
r1734 hg commit -m merge -d '2 0'
Matt Mackall
dispatch: add generic pre- and post-command hooks
r4630 # test generic hooks
hg id
Thomas Arendsen Hein
Kill trailing spaces
r4659 hg cat b
Matt Mackall
dispatch: add generic pre- and post-command hooks
r4630
Vadim Gelfer
tests for new hooks. fix things i found when writing tests.
r1734 cd ../b
hg pull ../a
# tag hooks can see env vars
cd ../a
Alexis S. L. Carvalho
test-hook: use printenv.py
r4286 echo 'pretag = python ../printenv.py pretag' >> .hg/hgrc
Thomas Arendsen Hein
Work around problem where 'del os.environ["FOO"]' doesn't update environment....
r4368 echo 'tag = unset HG_PARENT1 HG_PARENT2; python ../printenv.py tag' >> .hg/hgrc
Vadim Gelfer
tests for new hooks. fix things i found when writing tests.
r1734 hg tag -d '3 0' a
hg tag -l la
# pretag hook can forbid tagging
Alexis S. L. Carvalho
test-hook: use printenv.py
r4286 echo 'pretag.forbid = python ../printenv.py pretag.forbid 1' >> .hg/hgrc
Vadim Gelfer
tests for new hooks. fix things i found when writing tests.
r1734 hg tag -d '4 0' fa
hg tag -l fla
# pretxncommit hook can see changeset, can roll back txn, changeset
# no more there after
Alexis S. L. Carvalho
test-hook: use printenv.py
r4286 echo 'pretxncommit.forbid0 = hg tip -q' >> .hg/hgrc
echo 'pretxncommit.forbid1 = python ../printenv.py pretxncommit.forbid 1' >> .hg/hgrc
Vadim Gelfer
tests for new hooks. fix things i found when writing tests.
r1734 echo z > z
hg add z
hg -q tip
hg commit -m 'fail' -d '4 0'
hg -q tip
# precommit hook can prevent commit
Alexis S. L. Carvalho
test-hook: use printenv.py
r4286 echo 'precommit.forbid = python ../printenv.py precommit.forbid 1' >> .hg/hgrc
Vadim Gelfer
tests for new hooks. fix things i found when writing tests.
r1734 hg commit -m 'fail' -d '4 0'
hg -q tip
Vadim Gelfer
hooks: add preupdate and update hooks....
r2266 # preupdate hook can prevent update
Alexis S. L. Carvalho
test-hook: use printenv.py
r4286 echo 'preupdate = python ../printenv.py preupdate' >> .hg/hgrc
Vadim Gelfer
hooks: add preupdate and update hooks....
r2266 hg update 1
# update hook
Alexis S. L. Carvalho
test-hook: use printenv.py
r4286 echo 'update = python ../printenv.py update' >> .hg/hgrc
Vadim Gelfer
hooks: add preupdate and update hooks....
r2266 hg update
Vadim Gelfer
tests for new hooks. fix things i found when writing tests.
r1734 # prechangegroup hook can prevent incoming changes
cd ../b
hg -q tip
echo '[hooks]' > .hg/hgrc
Alexis S. L. Carvalho
test-hook: use printenv.py
r4286 echo 'prechangegroup.forbid = python ../printenv.py prechangegroup.forbid 1' >> .hg/hgrc
Vadim Gelfer
tests for new hooks. fix things i found when writing tests.
r1734 hg pull ../a
# pretxnchangegroup hook can see incoming changes, can roll back txn,
# incoming changes no longer there after
echo '[hooks]' > .hg/hgrc
Alexis S. L. Carvalho
test-hook: use printenv.py
r4286 echo 'pretxnchangegroup.forbid0 = hg tip -q' >> .hg/hgrc
echo 'pretxnchangegroup.forbid1 = python ../printenv.py pretxnchangegroup.forbid 1' >> .hg/hgrc
Vadim Gelfer
tests for new hooks. fix things i found when writing tests.
r1734 hg pull ../a
hg -q tip
Vadim Gelfer
add preoutgoing and outgoing hooks....
r1736
# outgoing hooks can see env vars
rm .hg/hgrc
echo '[hooks]' > ../a/.hg/hgrc
Alexis S. L. Carvalho
test-hook: use printenv.py
r4286 echo 'preoutgoing = python ../printenv.py preoutgoing' >> ../a/.hg/hgrc
echo 'outgoing = python ../printenv.py outgoing' >> ../a/.hg/hgrc
Vadim Gelfer
add preoutgoing and outgoing hooks....
r1736 hg pull ../a
Vadim Gelfer
deprecate undo command, replace with rollback command.
r2227 hg rollback
Vadim Gelfer
add preoutgoing and outgoing hooks....
r1736
# preoutgoing hook can prevent outgoing changes
Alexis S. L. Carvalho
test-hook: use printenv.py
r4286 echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> ../a/.hg/hgrc
Vadim Gelfer
add preoutgoing and outgoing hooks....
r1736 hg pull ../a
Fred Wulff
Add (pre)outgoing hooks for local clones.
r8907 # outgoing hooks work for local clones
cd ..
echo '[hooks]' > a/.hg/hgrc
echo 'preoutgoing = python ../printenv.py preoutgoing' >> a/.hg/hgrc
echo 'outgoing = python ../printenv.py outgoing' >> a/.hg/hgrc
hg clone a c
rm -rf c
# preoutgoing hook can prevent outgoing changes for local clones
echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> a/.hg/hgrc
hg clone a zzz
cd b
Vadim Gelfer
support hooks written in python....
r2155 cat > hooktests.py <<EOF
from mercurial import util
uncallable = 0
def printargs(args):
args.pop('ui', None)
args.pop('repo', None)
a = list(args.items())
a.sort()
print 'hook args:'
for k, v in a:
print ' ', k, v
def passhook(**args):
printargs(args)
def failhook(**args):
printargs(args)
Vadim Gelfer
reverse sense of return value from python hooks....
r2221 return True
Vadim Gelfer
support hooks written in python....
r2155
class LocalException(Exception):
pass
def raisehook(**args):
raise LocalException('exception from hook')
def aborthook(**args):
raise util.Abort('raise abort from hook')
def brokenhook(**args):
return 1 + {}
class container:
unreachable = 1
EOF
echo '# test python hooks'
Thomas Arendsen Hein
Applied $PWD fix (changeset 278f9b13c39a) to tests/test-hook, too.
r2164 PYTHONPATH="`pwd`:$PYTHONPATH"
Vadim Gelfer
support hooks written in python....
r2155 export PYTHONPATH
echo '[hooks]' > ../a/.hg/hgrc
echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
hg pull ../a 2>&1 | grep 'raised an exception'
echo '[hooks]' > ../a/.hg/hgrc
echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
hg pull ../a 2>&1 | grep 'raised an exception'
echo '[hooks]' > ../a/.hg/hgrc
echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
hg pull ../a
echo '[hooks]' > ../a/.hg/hgrc
echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
hg pull ../a
echo '[hooks]' > ../a/.hg/hgrc
echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
hg pull ../a
echo '[hooks]' > ../a/.hg/hgrc
echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
hg pull ../a
echo '[hooks]' > ../a/.hg/hgrc
echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
hg pull ../a
echo '[hooks]' > ../a/.hg/hgrc
echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
hg pull ../a
echo '[hooks]' > ../a/.hg/hgrc
echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
hg pull ../a
echo '[hooks]' > ../a/.hg/hgrc
echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
hg pull ../a
echo '# make sure --traceback works'
echo '[hooks]' > .hg/hgrc
echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
echo a >> a
hg --traceback commit -A -m a 2>&1 | grep '^Traceback'
Alexis S. L. Carvalho
Handle functions as the value of a hooks.<name> config variable...
r4070 cd ..
hg init c
cd c
cat > hookext.py <<EOF
def autohook(**args):
print "Automatically installed hook"
def reposetup(ui, repo):
repo.ui.setconfig("hooks", "commit.auto", autohook)
EOF
echo '[extensions]' >> .hg/hgrc
echo 'hookext = hookext.py' >> .hg/hgrc
touch foo
hg add foo
hg ci -m 'add foo'
echo >> foo
hg ci --debug -m 'change foo' | sed -e 's/ at .*>/>/'
Alexis S. L. Carvalho
Fix hg showconfig traceback with values that aren't strings
r4085 hg showconfig hooks | sed -e 's/ at .*>/>/'
Henri Wiechers
test python hook configured with python:[file]:[hook] syntax...
r9014 echo '# test python hook configured with python:[file]:[hook] syntax'
cd ..
mkdir d
cd d
hg init repo
mkdir hooks
cd hooks
cat > testhooks.py <<EOF
def testhook(**args):
print 'hook works'
EOF
echo '[hooks]' > ../repo/.hg/hgrc
echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
cd ../repo
hg commit
Vadim Gelfer
add preoutgoing and outgoing hooks....
r1736 exit 0