test-hook.t
707 lines
| 24.2 KiB
| text/troff
|
Tads3Lexer
/ tests / test-hook.t
|
r12328 | commit hooks can see env vars | ||
|
r24821 | (and post-transaction one are run unlocked) | ||
|
r11793 | |||
|
r25370 | $ cat << EOF >> $HGRCPATH | ||
> [experimental] | ||||
> # drop me once bundle2 is the default, | ||||
> # added to get test change early. | ||||
> bundle2-exp = True | ||||
> EOF | ||||
|
r25218 | $ cat > $TESTTMP/txnabort.checkargs.py <<EOF | ||
> def showargs(ui, repo, hooktype, **kwargs): | ||||
> ui.write('%s python hook: %s\n' % (hooktype, ','.join(sorted(kwargs)))) | ||||
> EOF | ||||
|
r11793 | $ hg init a | ||
$ cd a | ||||
|
r16964 | $ cat > .hg/hgrc <<EOF | ||
> [hooks] | ||||
|
r25478 | > commit = sh -c "HG_LOCAL= HG_TAG= printenv.py commit" | ||
> commit.b = sh -c "HG_LOCAL= HG_TAG= printenv.py commit.b" | ||||
> precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= printenv.py precommit" | ||||
> pretxncommit = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxncommit" | ||||
|
r16964 | > pretxncommit.tip = hg -q tip | ||
|
r25478 | > pre-identify = printenv.py pre-identify 1 | ||
> pre-cat = printenv.py pre-cat | ||||
> post-cat = printenv.py post-cat | ||||
> pretxnopen = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnopen" | ||||
> pretxnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnclose" | ||||
> txnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py txnclose" | ||||
|
r25218 | > txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs | ||
|
r25478 | > txnabort.1 = sh -c "HG_LOCAL= HG_TAG= printenv.py txnabort" | ||
|
r24827 | > txnclose.checklock = sh -c "hg debuglock > /dev/null" | ||
|
r16964 | > EOF | ||
|
r11793 | $ echo a > a | ||
$ hg add a | ||||
|
r12156 | $ hg commit -m a | ||
|
r16982 | precommit hook: HG_PARENT1=0000000000000000000000000000000000000000 | ||
|
r25268 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r16982 | pretxncommit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a | ||
|
r12156 | 0:cb9a9f314b8b | ||
|
r25219 | pretxnclose hook: HG_PENDING=$TESTTMP/a HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r24740 | txnclose hook: HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r16982 | commit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 | ||
commit.b hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 | ||||
|
r11793 | |||
$ hg clone . ../b | ||||
updating to branch default | ||||
1 files updated, 0 files merged, 0 files removed, 0 files unresolved | ||||
$ cd ../b | ||||
|
r12328 | changegroup hooks can see env vars | ||
|
r11793 | |||
|
r16964 | $ cat > .hg/hgrc <<EOF | ||
> [hooks] | ||||
|
r25478 | > prechangegroup = printenv.py prechangegroup | ||
> changegroup = printenv.py changegroup | ||||
> incoming = printenv.py incoming | ||||
|
r16964 | > EOF | ||
|
r11793 | |||
|
r12328 | pretxncommit and commit hooks can see both parents of merge | ||
|
r11793 | |||
$ cd ../a | ||||
$ echo b >> a | ||||
$ hg commit -m a1 -d "1 0" | ||||
|
r16982 | precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b | ||
|
r25268 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r16982 | pretxncommit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a | ||
|
r12156 | 1:ab228980c14d | ||
|
r25219 | pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r24740 | txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r16982 | commit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b | ||
commit.b hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b | ||||
|
r11793 | $ hg update -C 0 | ||
1 files updated, 0 files merged, 0 files removed, 0 files unresolved | ||||
$ echo b > b | ||||
$ hg add b | ||||
$ hg commit -m b -d '1 0' | ||||
|
r16982 | precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b | ||
|
r25268 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r16982 | pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a | ||
|
r12156 | 2:ee9deb46ab31 | ||
|
r25219 | pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r24740 | txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r16982 | commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b | ||
commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b | ||||
|
r11793 | created new head | ||
$ hg merge 1 | ||||
1 files updated, 0 files merged, 0 files removed, 0 files unresolved | ||||
(branch merge, don't forget to commit) | ||||
$ hg commit -m merge -d '2 0' | ||||
|
r16982 | precommit hook: HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd | ||
|
r25268 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r16982 | pretxncommit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a | ||
|
r12156 | 3:07f3376c1e65 | ||
|
r25219 | pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r24740 | txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r16982 | commit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd | ||
commit.b hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd | ||||
|
r11793 | |||
|
r12328 | test generic hooks | ||
|
r11793 | |||
$ hg id | ||||
|
r16982 | pre-identify hook: HG_ARGS=id HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None} HG_PATS=[] | ||
|
r19011 | abort: pre-identify hook exited with status 1 | ||
[255] | ||||
|
r11793 | $ hg cat b | ||
|
r16982 | pre-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b'] | ||
|
r13121 | b | ||
|
r16982 | post-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b'] HG_RESULT=0 | ||
|
r11793 | |||
$ cd ../b | ||||
$ hg pull ../a | ||||
|
r13439 | pulling from ../a | ||
searching for changes | ||||
|
r24740 | prechangegroup hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob) | ||
|
r13439 | adding changesets | ||
adding manifests | ||||
adding file changes | ||||
added 3 changesets with 2 changes to 2 files | ||||
|
r24740 | changegroup hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob) | ||
incoming hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob) | ||||
incoming hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob) | ||||
incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob) | ||||
|
r11793 | (run 'hg update' to get a working copy) | ||
|
r12328 | tag hooks can see env vars | ||
|
r11793 | |||
$ cd ../a | ||||
|
r16964 | $ cat >> .hg/hgrc <<EOF | ||
|
r25478 | > pretag = printenv.py pretag | ||
> tag = sh -c "HG_PARENT1= HG_PARENT2= printenv.py tag" | ||||
|
r16964 | > EOF | ||
|
r11793 | $ hg tag -d '3 0' a | ||
|
r16982 | pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a | ||
precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 | ||||
|
r25268 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r16982 | pretxncommit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a | ||
|
r12156 | 4:539e4b31b6dc | ||
|
r25219 | pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r16982 | tag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a | ||
|
r24740 | txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r16982 | commit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 | ||
commit.b hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 | ||||
|
r11793 | $ hg tag -l la | ||
|
r16982 | pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la | ||
tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la | ||||
|
r11793 | |||
|
r12328 | pretag hook can forbid tagging | ||
|
r11793 | |||
|
r25478 | $ echo "pretag.forbid = printenv.py pretag.forbid 1" >> .hg/hgrc | ||
|
r11793 | $ hg tag -d '4 0' fa | ||
|
r16982 | pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa | ||
pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa | ||||
|
r11793 | abort: pretag.forbid hook exited with status 1 | ||
|
r12316 | [255] | ||
|
r11793 | $ hg tag -l fla | ||
|
r16982 | pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla | ||
pretag.forbid hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla | ||||
|
r11793 | abort: pretag.forbid hook exited with status 1 | ||
|
r12316 | [255] | ||
|
r11793 | |||
|
r12328 | pretxncommit hook can see changeset, can roll back txn, changeset no | ||
more there after | ||||
|
r11793 | |||
|
r16964 | $ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc | ||
|
r25478 | $ echo "pretxncommit.forbid1 = printenv.py pretxncommit.forbid 1" >> .hg/hgrc | ||
|
r11793 | $ echo z > z | ||
$ hg add z | ||||
$ hg -q tip | ||||
|
r12156 | 4:539e4b31b6dc | ||
|
r11793 | $ hg commit -m 'fail' -d '4 0' | ||
|
r16982 | precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 | ||
|
r25268 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r16982 | pretxncommit hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a | ||
|
r12156 | 5:6f611f8018c1 | ||
5:6f611f8018c1 | ||||
|
r16982 | pretxncommit.forbid hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a | ||
|
r11793 | transaction abort! | ||
|
r25218 | txnabort python hook: txnid,txnname | ||
|
r24792 | txnabort hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob) | ||
|
r11793 | rollback completed | ||
abort: pretxncommit.forbid1 hook exited with status 1 | ||||
|
r12316 | [255] | ||
|
r11793 | $ hg -q tip | ||
|
r12156 | 4:539e4b31b6dc | ||
|
r11793 | |||
|
r23292 | (Check that no 'changelog.i.a' file were left behind) | ||
$ ls -1 .hg/store/ | ||||
00changelog.i | ||||
00manifest.i | ||||
data | ||||
fncache | ||||
journal.phaseroots | ||||
phaseroots | ||||
undo | ||||
|
r23904 | undo.backup.fncache | ||
undo.backupfiles | ||||
|
r23292 | undo.phaseroots | ||
|
r12328 | precommit hook can prevent commit | ||
|
r11793 | |||
|
r25478 | $ echo "precommit.forbid = printenv.py precommit.forbid 1" >> .hg/hgrc | ||
|
r11793 | $ hg commit -m 'fail' -d '4 0' | ||
|
r16982 | precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 | ||
precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 | ||||
|
r11793 | abort: precommit.forbid hook exited with status 1 | ||
|
r12316 | [255] | ||
|
r11793 | $ hg -q tip | ||
|
r12156 | 4:539e4b31b6dc | ||
|
r11793 | |||
|
r12328 | preupdate hook can prevent update | ||
|
r11793 | |||
|
r25478 | $ echo "preupdate = printenv.py preupdate" >> .hg/hgrc | ||
|
r11793 | $ hg update 1 | ||
|
r16982 | preupdate hook: HG_PARENT1=ab228980c14d | ||
|
r11793 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved | ||
|
r12328 | update hook | ||
|
r11793 | |||
|
r25478 | $ echo "update = printenv.py update" >> .hg/hgrc | ||
|
r11793 | $ hg update | ||
|
r16982 | preupdate hook: HG_PARENT1=539e4b31b6dc | ||
update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc | ||||
|
r11793 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | ||
|
r14102 | pushkey hook | ||
|
r25478 | $ echo "pushkey = printenv.py pushkey" >> .hg/hgrc | ||
|
r14102 | $ cd ../b | ||
$ hg bookmark -r null foo | ||||
$ hg push -B foo ../a | ||||
pushing to ../a | ||||
searching for changes | ||||
no changes found | ||||
|
r25370 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=push (glob) | ||
pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_PENDING=$TESTTMP/a HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=push (glob) | ||||
|
r22651 | pushkey hook: HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1 | ||
|
r25370 | txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=push (glob) | ||
|
r14102 | exporting bookmark foo | ||
|
r16038 | [1] | ||
|
r14102 | $ cd ../a | ||
listkeys hook | ||||
|
r25478 | $ echo "listkeys = printenv.py listkeys" >> .hg/hgrc | ||
|
r14102 | $ hg bookmark -r null bar | ||
$ cd ../b | ||||
$ hg pull -B bar ../a | ||||
pulling from ../a | ||||
|
r16982 | listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'} | ||
|
r25370 | no changes found | ||
listkeys hook: HG_NAMESPACE=phase HG_VALUES={} | ||||
adding remote bookmark bar | ||||
|
r16982 | listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'} | ||
|
r14102 | $ cd ../a | ||
test that prepushkey can prevent incoming keys | ||||
|
r25478 | $ echo "prepushkey = printenv.py prepushkey.forbid 1" >> .hg/hgrc | ||
|
r14102 | $ cd ../b | ||
$ hg bookmark -r null baz | ||||
$ hg push -B baz ../a | ||||
pushing to ../a | ||||
searching for changes | ||||
|
r22019 | listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'} | ||
|
r22239 | listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'} | ||
|
r14102 | no changes found | ||
|
r25370 | pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=push (glob) | ||
prepushkey.forbid hook: HG_BUNDLE2=1 HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_SOURCE=push HG_TXNID=TXN:* HG_URL=push (glob) | ||||
pushkey-abort: prepushkey hook exited with status 1 | ||||
pretxnclose hook: HG_BUNDLE2=1 HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=push (glob) | ||||
txnclose hook: HG_BUNDLE2=1 HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=push (glob) | ||||
exporting bookmark baz failed! | ||||
|
r16982 | listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'} | ||
|
r23416 | [1] | ||
|
r14102 | $ cd ../a | ||
test that prelistkeys can prevent listing keys | ||||
|
r25478 | $ echo "prelistkeys = printenv.py prelistkeys.forbid 1" >> .hg/hgrc | ||
|
r14102 | $ hg bookmark -r null quux | ||
$ cd ../b | ||||
$ hg pull -B quux ../a | ||||
pulling from ../a | ||||
|
r16982 | prelistkeys.forbid hook: HG_NAMESPACE=bookmarks | ||
|
r14102 | abort: prelistkeys hook exited with status 1 | ||
[255] | ||||
$ cd ../a | ||||
|
r18850 | $ rm .hg/hgrc | ||
|
r14102 | |||
|
r12328 | prechangegroup hook can prevent incoming changes | ||
|
r11793 | |||
$ cd ../b | ||||
$ hg -q tip | ||||
|
r12156 | 3:07f3376c1e65 | ||
|
r16964 | $ cat > .hg/hgrc <<EOF | ||
> [hooks] | ||||
|
r25478 | > prechangegroup.forbid = printenv.py prechangegroup.forbid 1 | ||
|
r16964 | > EOF | ||
|
r11793 | $ hg pull ../a | ||
pulling from ../a | ||||
searching for changes | ||||
|
r24740 | prechangegroup.forbid hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob) | ||
|
r11793 | abort: prechangegroup.forbid hook exited with status 1 | ||
|
r12316 | [255] | ||
|
r11793 | |||
|
r12328 | pretxnchangegroup hook can see incoming changes, can roll back txn, | ||
incoming changes no longer there after | ||||
|
r11793 | |||
|
r16964 | $ cat > .hg/hgrc <<EOF | ||
> [hooks] | ||||
> pretxnchangegroup.forbid0 = hg tip -q | ||||
|
r25478 | > pretxnchangegroup.forbid1 = printenv.py pretxnchangegroup.forbid 1 | ||
|
r16964 | > EOF | ||
|
r11793 | $ hg pull ../a | ||
pulling from ../a | ||||
searching for changes | ||||
adding changesets | ||||
adding manifests | ||||
adding file changes | ||||
added 1 changesets with 1 changes to 1 files | ||||
|
r13439 | 4:539e4b31b6dc | ||
|
r24740 | pretxnchangegroup.forbid hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob) | ||
|
r11793 | transaction abort! | ||
rollback completed | ||||
abort: pretxnchangegroup.forbid1 hook exited with status 1 | ||||
|
r12316 | [255] | ||
|
r11793 | $ hg -q tip | ||
|
r12156 | 3:07f3376c1e65 | ||
|
r11793 | |||
|
r12328 | outgoing hooks can see env vars | ||
|
r11793 | |||
$ rm .hg/hgrc | ||||
|
r16964 | $ cat > ../a/.hg/hgrc <<EOF | ||
> [hooks] | ||||
|
r25478 | > preoutgoing = printenv.py preoutgoing | ||
> outgoing = printenv.py outgoing | ||||
|
r16964 | > EOF | ||
|
r11793 | $ hg pull ../a | ||
pulling from ../a | ||||
searching for changes | ||||
|
r16982 | preoutgoing hook: HG_SOURCE=pull | ||
|
r25370 | outgoing hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull | ||
|
r11793 | adding changesets | ||
adding manifests | ||||
adding file changes | ||||
added 1 changesets with 1 changes to 1 files | ||||
|
r16697 | adding remote bookmark quux | ||
|
r11793 | (run 'hg update' to get a working copy) | ||
$ hg rollback | ||||
|
r13446 | repository tip rolled back to revision 3 (undo pull) | ||
|
r11793 | |||
|
r12328 | preoutgoing hook can prevent outgoing changes | ||
|
r11793 | |||
|
r25478 | $ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> ../a/.hg/hgrc | ||
|
r11793 | $ hg pull ../a | ||
|
r13439 | pulling from ../a | ||
searching for changes | ||||
|
r16982 | preoutgoing hook: HG_SOURCE=pull | ||
preoutgoing.forbid hook: HG_SOURCE=pull | ||||
|
r11793 | abort: preoutgoing.forbid hook exited with status 1 | ||
|
r12316 | [255] | ||
|
r11793 | |||
|
r12328 | outgoing hooks work for local clones | ||
|
r11793 | |||
$ cd .. | ||||
|
r16964 | $ cat > a/.hg/hgrc <<EOF | ||
> [hooks] | ||||
|
r25478 | > preoutgoing = printenv.py preoutgoing | ||
> outgoing = printenv.py outgoing | ||||
|
r16964 | > EOF | ||
|
r11793 | $ hg clone a c | ||
|
r16982 | preoutgoing hook: HG_SOURCE=clone | ||
outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone | ||||
|
r11793 | updating to branch default | ||
3 files updated, 0 files merged, 0 files removed, 0 files unresolved | ||||
$ rm -rf c | ||||
|
r12328 | preoutgoing hook can prevent outgoing changes for local clones | ||
|
r11793 | |||
|
r25478 | $ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> a/.hg/hgrc | ||
|
r11793 | $ hg clone a zzz | ||
|
r16982 | preoutgoing hook: HG_SOURCE=clone | ||
preoutgoing.forbid hook: HG_SOURCE=clone | ||||
|
r11793 | abort: preoutgoing.forbid hook exited with status 1 | ||
|
r12316 | [255] | ||
|
r16964 | |||
$ cd "$TESTTMP/b" | ||||
|
r11793 | |||
$ 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) | ||||
> return True | ||||
> | ||||
> 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 + {} | ||||
> | ||||
|
r14601 | > def verbosehook(ui, **args): | ||
> ui.note('verbose output from hook\n') | ||||
> | ||||
|
r15929 | > def printtags(ui, repo, **args): | ||
|
r18377 | > print sorted(repo.tags()) | ||
|
r15929 | > | ||
|
r11793 | > class container: | ||
> unreachable = 1 | ||||
> EOF | ||||
|
r12328 | test python hooks | ||
|
r11793 | |||
|
r16964 | #if windows | ||
$ PYTHONPATH="$TESTTMP/b;$PYTHONPATH" | ||||
#else | ||||
$ PYTHONPATH="$TESTTMP/b:$PYTHONPATH" | ||||
#endif | ||||
|
r11793 | $ 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' | ||||
error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict' | ||||
$ echo '[hooks]' > ../a/.hg/hgrc | ||||
$ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc | ||||
$ hg pull ../a 2>&1 | grep 'raised an exception' | ||||
error: preoutgoing.raise hook raised an exception: exception from hook | ||||
$ echo '[hooks]' > ../a/.hg/hgrc | ||||
$ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc | ||||
$ hg pull ../a | ||||
pulling from ../a | ||||
searching for changes | ||||
error: preoutgoing.abort hook failed: raise abort from hook | ||||
abort: raise abort from hook | ||||
|
r12316 | [255] | ||
|
r11793 | |||
$ echo '[hooks]' > ../a/.hg/hgrc | ||||
$ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc | ||||
$ hg pull ../a | ||||
pulling from ../a | ||||
searching for changes | ||||
hook args: | ||||
hooktype preoutgoing | ||||
source pull | ||||
abort: preoutgoing.fail hook failed | ||||
|
r12316 | [255] | ||
|
r11793 | |||
$ echo '[hooks]' > ../a/.hg/hgrc | ||||
$ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc | ||||
$ hg pull ../a | ||||
pulling from ../a | ||||
searching for changes | ||||
abort: preoutgoing.uncallable hook is invalid ("hooktests.uncallable" is not callable) | ||||
|
r12316 | [255] | ||
|
r11793 | |||
$ echo '[hooks]' > ../a/.hg/hgrc | ||||
$ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc | ||||
$ hg pull ../a | ||||
pulling from ../a | ||||
searching for changes | ||||
abort: preoutgoing.nohook hook is invalid ("hooktests.nohook" is not defined) | ||||
|
r12316 | [255] | ||
|
r11793 | |||
$ echo '[hooks]' > ../a/.hg/hgrc | ||||
$ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc | ||||
$ hg pull ../a | ||||
pulling from ../a | ||||
searching for changes | ||||
abort: preoutgoing.nomodule hook is invalid ("nomodule" not in a module) | ||||
|
r12316 | [255] | ||
|
r11793 | |||
$ echo '[hooks]' > ../a/.hg/hgrc | ||||
$ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc | ||||
$ hg pull ../a | ||||
pulling from ../a | ||||
searching for changes | ||||
abort: preoutgoing.badmodule hook is invalid (import of "nomodule" failed) | ||||
|
r12316 | [255] | ||
|
r11793 | |||
$ echo '[hooks]' > ../a/.hg/hgrc | ||||
$ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc | ||||
$ hg pull ../a | ||||
pulling from ../a | ||||
searching for changes | ||||
abort: preoutgoing.unreachable hook is invalid (import of "hooktests.container" failed) | ||||
|
r12316 | [255] | ||
|
r11793 | |||
$ echo '[hooks]' > ../a/.hg/hgrc | ||||
$ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc | ||||
$ hg pull ../a | ||||
pulling from ../a | ||||
searching for changes | ||||
hook args: | ||||
hooktype preoutgoing | ||||
source pull | ||||
adding changesets | ||||
adding manifests | ||||
adding file changes | ||||
added 1 changesets with 1 changes to 1 files | ||||
|
r16697 | adding remote bookmark quux | ||
|
r11793 | (run 'hg update' to get a working copy) | ||
|
r12328 | make sure --traceback works | ||
|
r11793 | |||
$ echo '[hooks]' > .hg/hgrc | ||||
$ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc | ||||
$ echo aa > a | ||||
$ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback' | ||||
Traceback (most recent call last): | ||||
$ 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 -d '0 0' -m 'add foo' | ||||
Automatically installed hook | ||||
$ echo >> foo | ||||
|
r11794 | $ hg ci --debug -d '0 0' -m 'change foo' | ||
|
r23749 | committing files: | ||
|
r11793 | foo | ||
|
r23749 | committing manifest | ||
committing changelog | ||||
|
r20548 | calling hook commit.auto: hgext_hookext.autohook | ||
|
r11793 | Automatically installed hook | ||
committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708 | ||||
|
r11794 | $ hg showconfig hooks | ||
|
r12376 | hooks.commit.auto=<function autohook at *> (glob) | ||
|
r11793 | |||
|
r12328 | test python hook configured with python:[file]:[hook] syntax | ||
|
r11793 | |||
$ 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 -d '0 0' | ||||
hook works | ||||
nothing changed | ||||
|
r12316 | [1] | ||
|
r11793 | |||
|
r17217 | $ echo '[hooks]' > .hg/hgrc | ||
|
r17492 | $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc | ||
|
r17217 | $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc | ||
$ hg up null | ||||
loading update.ne hook failed: | ||||
|
r17492 | abort: No such file or directory: $TESTTMP/d/repo/nonexistent.py | ||
|
r17217 | [255] | ||
$ hg id | ||||
loading pre-identify.npmd hook failed: | ||||
abort: No module named repo! | ||||
[255] | ||||
|
r11793 | $ cd ../../b | ||
|
r12328 | make sure --traceback works on hook import failure | ||
|
r11793 | |||
$ cat > importfail.py <<EOF | ||||
> import somebogusmodule | ||||
> # dereference something in the module to force demandimport to load it | ||||
> somebogusmodule.whatever | ||||
> EOF | ||||
$ echo '[hooks]' > .hg/hgrc | ||||
$ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc | ||||
$ echo a >> a | ||||
|
r17283 | $ hg --traceback commit -ma 2>&1 | egrep -v '^( +File| [a-zA-Z(])' | ||
|
r11793 | exception from first failed import attempt: | ||
Traceback (most recent call last): | ||||
ImportError: No module named somebogusmodule | ||||
exception from second failed import attempt: | ||||
Traceback (most recent call last): | ||||
ImportError: No module named hgext_importfail | ||||
Traceback (most recent call last): | ||||
|
r17166 | Abort: precommit.importfail hook is invalid (import of "importfail" failed) | ||
abort: precommit.importfail hook is invalid (import of "importfail" failed) | ||||
|
r11793 | |||
|
r12399 | Issue1827: Hooks Update & Commit not completely post operation | ||
|
r24881 | commit and update hooks should run after command completion. The largefiles | ||
use demonstrates a recursive wlock, showing the hook doesn't run until the | ||||
final release (and dirstate flush). | ||||
|
r11793 | |||
$ echo '[hooks]' > .hg/hgrc | ||||
$ echo 'commit = hg id' >> .hg/hgrc | ||||
$ echo 'update = hg id' >> .hg/hgrc | ||||
$ echo bb > a | ||||
|
r12156 | $ hg ci -ma | ||
223eafe2750c tip | ||||
|
r24881 | $ hg up 0 --config extensions.largefiles= | ||
|
r12156 | cb9a9f314b8b | ||
|
r11793 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | ||
|
r17508 | make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui | ||
|
r14601 | that is passed to pre/post hooks | ||
$ echo '[hooks]' > .hg/hgrc | ||||
$ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc | ||||
$ hg id | ||||
cb9a9f314b8b | ||||
$ hg id --verbose | ||||
calling hook pre-identify: hooktests.verbosehook | ||||
verbose output from hook | ||||
cb9a9f314b8b | ||||
|
r15896 | |||
Ensure hooks can be prioritized | ||||
$ echo '[hooks]' > .hg/hgrc | ||||
$ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc | ||||
$ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc | ||||
$ echo 'priority.pre-identify.b = 1' >> .hg/hgrc | ||||
$ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc | ||||
$ hg id --verbose | ||||
calling hook pre-identify.b: hooktests.verbosehook | ||||
verbose output from hook | ||||
calling hook pre-identify.a: hooktests.verbosehook | ||||
verbose output from hook | ||||
calling hook pre-identify.c: hooktests.verbosehook | ||||
verbose output from hook | ||||
cb9a9f314b8b | ||||
|
r15929 | |||
new tags must be visible in pretxncommit (issue3210) | ||||
$ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc | ||||
$ hg tag -f foo | ||||
['a', 'foo', 'tip'] | ||||
|
r16619 | new commits must be visible in pretxnchangegroup (issue3428) | ||
$ cd .. | ||||
$ hg init to | ||||
$ echo '[hooks]' >> to/.hg/hgrc | ||||
$ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc | ||||
$ echo a >> to/a | ||||
$ hg --cwd to ci -Ama | ||||
adding a | ||||
$ hg clone to from | ||||
updating to branch default | ||||
1 files updated, 0 files merged, 0 files removed, 0 files unresolved | ||||
$ echo aa >> from/a | ||||
$ hg --cwd from ci -mb | ||||
$ hg --cwd from push | ||||
|
r16964 | pushing to $TESTTMP/to (glob) | ||
|
r16619 | searching for changes | ||
adding changesets | ||||
adding manifests | ||||
adding file changes | ||||
added 1 changesets with 1 changes to 1 files | ||||
changeset: 1:9836a07b9b9d | ||||
tag: tip | ||||
user: test | ||||
date: Thu Jan 01 00:00:00 1970 +0000 | ||||
summary: b | ||||