##// END OF EJS Templates
rollback: only restore dirstate and branch when appropriate....
rollback: only restore dirstate and branch when appropriate. If the working dir parent was destroyed by rollback, then the old behaviour is perfectly reasonable: restore dirstate, branch, and bookmarks. That way the working dir moves back to an existing changeset rather than becoming an orphan. But if the working dir parent was unaffected -- say, you updated to an older changeset and then did rollback -- then it's silly to restore dirstate and branch. So don't do that. Leave the status of the working dir alone. (But always restore bookmarks, because that file refers to changeset IDs that may have been destroyed.)

File last commit:

r15131:7c26ce9e default
r15131:7c26ce9e default
Show More
test-hook.t
550 lines | 19.5 KiB | text/troff | Tads3Lexer
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 commit hooks can see env vars
Nicolas Dumazet
tests: unify test-hook
r11793
$ hg init a
$ cd a
$ echo "[hooks]" > .hg/hgrc
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'commit = unset HG_LOCAL HG_TAG; python "$TESTDIR"/printenv.py commit' >> .hg/hgrc
$ echo 'commit.b = unset HG_LOCAL HG_TAG; python "$TESTDIR"/printenv.py commit.b' >> .hg/hgrc
$ echo 'precommit = unset HG_LOCAL HG_NODE HG_TAG; python "$TESTDIR"/printenv.py precommit' >> .hg/hgrc
$ echo 'pretxncommit = unset HG_LOCAL HG_TAG; python "$TESTDIR"/printenv.py pretxncommit' >> .hg/hgrc
Nicolas Dumazet
tests: unify test-hook
r11793 $ echo 'pretxncommit.tip = hg -q tip' >> .hg/hgrc
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'pre-identify = python "$TESTDIR"/printenv.py pre-identify 1' >> .hg/hgrc
$ echo 'pre-cat = python "$TESTDIR"/printenv.py pre-cat' >> .hg/hgrc
$ echo 'post-cat = python "$TESTDIR"/printenv.py post-cat' >> .hg/hgrc
Nicolas Dumazet
tests: unify test-hook
r11793 $ echo a > a
$ hg add a
Martin Geisler
tests: remove unneeded -d flags...
r12156 $ hg commit -m a
Nicolas Dumazet
tests: unify test-hook
r11793 precommit hook: HG_PARENT1=0000000000000000000000000000000000000000
Mads Kiilerich
tests: remove redundant globs...
r12640 pretxncommit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a
Martin Geisler
tests: remove unneeded -d flags...
r12156 0:cb9a9f314b8b
commit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
commit.b hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
Nicolas Dumazet
tests: unify test-hook
r11793
$ hg clone . ../b
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd ../b
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 changegroup hooks can see env vars
Nicolas Dumazet
tests: unify test-hook
r11793
$ echo '[hooks]' > .hg/hgrc
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'prechangegroup = python "$TESTDIR"/printenv.py prechangegroup' >> .hg/hgrc
$ echo 'changegroup = python "$TESTDIR"/printenv.py changegroup' >> .hg/hgrc
$ echo 'incoming = python "$TESTDIR"/printenv.py incoming' >> .hg/hgrc
Nicolas Dumazet
tests: unify test-hook
r11793
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 pretxncommit and commit hooks can see both parents of merge
Nicolas Dumazet
tests: unify test-hook
r11793
$ cd ../a
$ echo b >> a
$ hg commit -m a1 -d "1 0"
Martin Geisler
tests: remove unneeded -d flags...
r12156 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
Mads Kiilerich
tests: remove redundant globs...
r12640 pretxncommit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
Martin Geisler
tests: remove unneeded -d flags...
r12156 1:ab228980c14d
commit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
commit.b hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
Nicolas Dumazet
tests: unify test-hook
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'
Martin Geisler
tests: remove unneeded -d flags...
r12156 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
Mads Kiilerich
tests: remove redundant globs...
r12640 pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
Martin Geisler
tests: remove unneeded -d flags...
r12156 2:ee9deb46ab31
commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
Nicolas Dumazet
tests: unify test-hook
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'
Martin Geisler
tests: remove unneeded -d flags...
r12156 precommit hook: HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
Mads Kiilerich
tests: remove redundant globs...
r12640 pretxncommit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a
Martin Geisler
tests: remove unneeded -d flags...
r12156 3:07f3376c1e65
commit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
commit.b hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
Nicolas Dumazet
tests: unify test-hook
r11793
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 test generic hooks
Nicolas Dumazet
tests: unify test-hook
r11793
$ hg id
Kevin Bullock
id: add bookmarks to id...
r13477 pre-identify hook: HG_ARGS=id HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'num': None, 'rev': '', 'tags': None} HG_PATS=[]
Nicolas Dumazet
tests: unify test-hook
r11793 warning: pre-identify hook exited with status 1
Matt Mackall
tests: add exit codes to unified tests
r12316 [1]
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg cat b
Dan Villiom Podlaski Christiansen
hooks: sort any dictionaries set in the environment...
r13207 pre-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b']
Dan Villiom Podlaski Christiansen
make_file: always return a fresh file handle that can be closed...
r13121 b
Dan Villiom Podlaski Christiansen
hooks: sort any dictionaries set in the environment...
r13207 post-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b'] HG_RESULT=0
Nicolas Dumazet
tests: unify test-hook
r11793
$ cd ../b
$ hg pull ../a
Mads Kiilerich
util: flush stdout before calling external processes...
r13439 pulling from ../a
searching for changes
Mads Kiilerich
tests: let printenv.py show the real values...
r13404 prechangegroup hook: HG_SOURCE=pull HG_URL=file:$TESTTMP/a
Mads Kiilerich
util: flush stdout before calling external processes...
r13439 adding changesets
adding manifests
adding file changes
added 3 changesets with 2 changes to 2 files
Mads Kiilerich
tests: let printenv.py show the real values...
r13404 changegroup hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_URL=file:$TESTTMP/a
incoming hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_URL=file:$TESTTMP/a
incoming hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_URL=file:$TESTTMP/a
incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_URL=file:$TESTTMP/a
Nicolas Dumazet
tests: unify test-hook
r11793 (run 'hg update' to get a working copy)
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 tag hooks can see env vars
Nicolas Dumazet
tests: unify test-hook
r11793
$ cd ../a
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'pretag = python "$TESTDIR"/printenv.py pretag' >> .hg/hgrc
$ echo 'tag = unset HG_PARENT1 HG_PARENT2; python "$TESTDIR"/printenv.py tag' >> .hg/hgrc
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg tag -d '3 0' a
Martin Geisler
tests: remove unneeded -d flags...
r12156 pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
Mads Kiilerich
tests: remove redundant globs...
r12640 pretxncommit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a
Martin Geisler
tests: remove unneeded -d flags...
r12156 4:539e4b31b6dc
commit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
commit.b hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
tag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg tag -l la
Martin Geisler
tests: remove unneeded -d flags...
r12156 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
Nicolas Dumazet
tests: unify test-hook
r11793
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 pretag hook can forbid tagging
Nicolas Dumazet
tests: unify test-hook
r11793
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'pretag.forbid = python "$TESTDIR"/printenv.py pretag.forbid 1' >> .hg/hgrc
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg tag -d '4 0' fa
Martin Geisler
tests: remove unneeded -d flags...
r12156 pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
Nicolas Dumazet
tests: unify test-hook
r11793 abort: pretag.forbid hook exited with status 1
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg tag -l fla
Martin Geisler
tests: remove unneeded -d flags...
r12156 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
pretag.forbid hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
Nicolas Dumazet
tests: unify test-hook
r11793 abort: pretag.forbid hook exited with status 1
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
r11793
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 pretxncommit hook can see changeset, can roll back txn, changeset no
more there after
Nicolas Dumazet
tests: unify test-hook
r11793
$ echo 'pretxncommit.forbid0 = hg tip -q' >> .hg/hgrc
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'pretxncommit.forbid1 = python "$TESTDIR"/printenv.py pretxncommit.forbid 1' >> .hg/hgrc
Nicolas Dumazet
tests: unify test-hook
r11793 $ echo z > z
$ hg add z
$ hg -q tip
Martin Geisler
tests: remove unneeded -d flags...
r12156 4:539e4b31b6dc
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg commit -m 'fail' -d '4 0'
Martin Geisler
tests: remove unneeded -d flags...
r12156 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
Mads Kiilerich
tests: remove redundant globs...
r12640 pretxncommit hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
Martin Geisler
tests: remove unneeded -d flags...
r12156 5:6f611f8018c1
5:6f611f8018c1
Mads Kiilerich
tests: remove redundant globs...
r12640 pretxncommit.forbid hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
Nicolas Dumazet
tests: unify test-hook
r11793 transaction abort!
rollback completed
abort: pretxncommit.forbid1 hook exited with status 1
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg -q tip
Martin Geisler
tests: remove unneeded -d flags...
r12156 4:539e4b31b6dc
Nicolas Dumazet
tests: unify test-hook
r11793
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 precommit hook can prevent commit
Nicolas Dumazet
tests: unify test-hook
r11793
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'precommit.forbid = python "$TESTDIR"/printenv.py precommit.forbid 1' >> .hg/hgrc
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg commit -m 'fail' -d '4 0'
Martin Geisler
tests: remove unneeded -d flags...
r12156 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
Nicolas Dumazet
tests: unify test-hook
r11793 abort: precommit.forbid hook exited with status 1
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg -q tip
Martin Geisler
tests: remove unneeded -d flags...
r12156 4:539e4b31b6dc
Nicolas Dumazet
tests: unify test-hook
r11793
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 preupdate hook can prevent update
Nicolas Dumazet
tests: unify test-hook
r11793
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'preupdate = python "$TESTDIR"/printenv.py preupdate' >> .hg/hgrc
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg update 1
Martin Geisler
tests: remove unneeded -d flags...
r12156 preupdate hook: HG_PARENT1=ab228980c14d
Nicolas Dumazet
tests: unify test-hook
r11793 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 update hook
Nicolas Dumazet
tests: unify test-hook
r11793
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'update = python "$TESTDIR"/printenv.py update' >> .hg/hgrc
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg update
Martin Geisler
tests: remove unneeded -d flags...
r12156 preupdate hook: HG_PARENT1=539e4b31b6dc
update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc
Nicolas Dumazet
tests: unify test-hook
r11793 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
Brodie Rao
pushkey: add hooks for pushkey/listkeys
r14102 pushkey hook
$ echo 'pushkey = python "$TESTDIR"/printenv.py pushkey' >> .hg/hgrc
$ cd ../b
$ hg bookmark -r null foo
$ hg push -B foo ../a
pushing to ../a
searching for changes
no changes found
exporting bookmark foo
pushkey hook: HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1
$ cd ../a
listkeys hook
$ echo 'listkeys = python "$TESTDIR"/printenv.py listkeys' >> .hg/hgrc
$ hg bookmark -r null bar
$ cd ../b
$ hg pull -B bar ../a
pulling from ../a
listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
Peter Arrenbrecht
discovery: add new set-based discovery...
r14164 no changes found
Brodie Rao
pushkey: add hooks for pushkey/listkeys
r14102 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
importing bookmark bar
$ cd ../a
test that prepushkey can prevent incoming keys
$ echo 'prepushkey = python "$TESTDIR"/printenv.py prepushkey.forbid 1' >> .hg/hgrc
$ cd ../b
$ hg bookmark -r null baz
$ hg push -B baz ../a
pushing to ../a
searching for changes
no changes found
listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
exporting bookmark baz
prepushkey.forbid hook: HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000
abort: prepushkey hook exited with status 1
[255]
$ cd ../a
test that prelistkeys can prevent listing keys
$ echo 'prelistkeys = python "$TESTDIR"/printenv.py prelistkeys.forbid 1' >> .hg/hgrc
$ hg bookmark -r null quux
$ cd ../b
$ hg pull -B quux ../a
pulling from ../a
prelistkeys.forbid hook: HG_NAMESPACE=bookmarks
abort: prelistkeys hook exited with status 1
[255]
$ cd ../a
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 prechangegroup hook can prevent incoming changes
Nicolas Dumazet
tests: unify test-hook
r11793
$ cd ../b
$ hg -q tip
Martin Geisler
tests: remove unneeded -d flags...
r12156 3:07f3376c1e65
Nicolas Dumazet
tests: unify test-hook
r11793 $ echo '[hooks]' > .hg/hgrc
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'prechangegroup.forbid = python "$TESTDIR"/printenv.py prechangegroup.forbid 1' >> .hg/hgrc
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg pull ../a
pulling from ../a
searching for changes
Mads Kiilerich
util: flush stdout before calling external processes...
r13439 prechangegroup.forbid hook: HG_SOURCE=pull HG_URL=file:$TESTTMP/a
Nicolas Dumazet
tests: unify test-hook
r11793 abort: prechangegroup.forbid hook exited with status 1
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
r11793
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 pretxnchangegroup hook can see incoming changes, can roll back txn,
incoming changes no longer there after
Nicolas Dumazet
tests: unify test-hook
r11793
$ echo '[hooks]' > .hg/hgrc
$ echo 'pretxnchangegroup.forbid0 = hg tip -q' >> .hg/hgrc
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'pretxnchangegroup.forbid1 = python "$TESTDIR"/printenv.py pretxnchangegroup.forbid 1' >> .hg/hgrc
Nicolas Dumazet
tests: unify test-hook
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
Mads Kiilerich
util: flush stdout before calling external processes...
r13439 4:539e4b31b6dc
pretxnchangegroup.forbid hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_URL=file:$TESTTMP/a
Nicolas Dumazet
tests: unify test-hook
r11793 transaction abort!
rollback completed
abort: pretxnchangegroup.forbid1 hook exited with status 1
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg -q tip
Martin Geisler
tests: remove unneeded -d flags...
r12156 3:07f3376c1e65
Nicolas Dumazet
tests: unify test-hook
r11793
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 outgoing hooks can see env vars
Nicolas Dumazet
tests: unify test-hook
r11793
$ rm .hg/hgrc
$ echo '[hooks]' > ../a/.hg/hgrc
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'preoutgoing = python "$TESTDIR"/printenv.py preoutgoing' >> ../a/.hg/hgrc
$ echo 'outgoing = python "$TESTDIR"/printenv.py outgoing' >> ../a/.hg/hgrc
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg pull ../a
pulling from ../a
searching for changes
Mads Kiilerich
util: flush stdout before calling external processes...
r13439 preoutgoing hook: HG_SOURCE=pull
Nicolas Dumazet
tests: unify test-hook
r11793 adding changesets
Mads Kiilerich
util: flush stdout before calling external processes...
r13439 outgoing hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull
Nicolas Dumazet
tests: unify test-hook
r11793 adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
(run 'hg update' to get a working copy)
$ hg rollback
Gilles Moris
rollback: clarifies the message about the reverted state (issue2628)...
r13446 repository tip rolled back to revision 3 (undo pull)
Nicolas Dumazet
tests: unify test-hook
r11793
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 preoutgoing hook can prevent outgoing changes
Nicolas Dumazet
tests: unify test-hook
r11793
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'preoutgoing.forbid = python "$TESTDIR"/printenv.py preoutgoing.forbid 1' >> ../a/.hg/hgrc
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg pull ../a
Mads Kiilerich
util: flush stdout before calling external processes...
r13439 pulling from ../a
searching for changes
Nicolas Dumazet
tests: unify test-hook
r11793 preoutgoing hook: HG_SOURCE=pull
preoutgoing.forbid hook: HG_SOURCE=pull
abort: preoutgoing.forbid hook exited with status 1
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
r11793
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 outgoing hooks work for local clones
Nicolas Dumazet
tests: unify test-hook
r11793
$ cd ..
$ echo '[hooks]' > a/.hg/hgrc
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'preoutgoing = python "$TESTDIR"/printenv.py preoutgoing' >> a/.hg/hgrc
$ echo 'outgoing = python "$TESTDIR"/printenv.py outgoing' >> a/.hg/hgrc
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg clone a c
preoutgoing hook: HG_SOURCE=clone
outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone
updating to branch default
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ rm -rf c
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 preoutgoing hook can prevent outgoing changes for local clones
Nicolas Dumazet
tests: unify test-hook
r11793
Mads Kiilerich
tests: use printenv.py where it is - don't copy it around
r13405 $ echo 'preoutgoing.forbid = python "$TESTDIR"/printenv.py preoutgoing.forbid 1' >> a/.hg/hgrc
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg clone a zzz
preoutgoing hook: HG_SOURCE=clone
preoutgoing.forbid hook: HG_SOURCE=clone
abort: preoutgoing.forbid hook exited with status 1
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
r11793 $ cd b
$ 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 + {}
>
Idan Kamara
dispatch: propagate ui command options to the local ui (issue2523)...
r14601 > def verbosehook(ui, **args):
> ui.note('verbose output from hook\n')
>
Nicolas Dumazet
tests: unify test-hook
r11793 > class container:
> unreachable = 1
> EOF
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 test python hooks
Nicolas Dumazet
tests: unify test-hook
r11793
$ PYTHONPATH="`pwd`:$PYTHONPATH"
$ 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
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
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
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
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)
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
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)
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
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)
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
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)
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
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)
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-hook
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
(run 'hg update' to get a working copy)
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 make sure --traceback works
Nicolas Dumazet
tests: unify test-hook
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
Nicolas Dumazet
tests: remove useless sed in test-hook
r11794 $ hg ci --debug -d '0 0' -m 'change foo'
Nicolas Dumazet
tests: unify test-hook
r11793 foo
Brodie Rao
tests: add glob matching for unified tests...
r12376 calling hook commit.auto: <function autohook at *> (glob)
Nicolas Dumazet
tests: unify test-hook
r11793 Automatically installed hook
committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
Nicolas Dumazet
tests: remove useless sed in test-hook
r11794 $ hg showconfig hooks
Brodie Rao
tests: add glob matching for unified tests...
r12376 hooks.commit.auto=<function autohook at *> (glob)
Nicolas Dumazet
tests: unify test-hook
r11793
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 test python hook configured with python:[file]:[hook] syntax
Nicolas Dumazet
tests: unify test-hook
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
Matt Mackall
tests: add exit codes to unified tests
r12316 [1]
Nicolas Dumazet
tests: unify test-hook
r11793
$ cd ../../b
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 make sure --traceback works on hook import failure
Nicolas Dumazet
tests: unify test-hook
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
Martin Geisler
tests: remove unneeded -d flags...
r12156 $ hg --traceback commit -ma 2>&1 | egrep '^(exception|Traceback|ImportError)'
Nicolas Dumazet
tests: unify test-hook
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):
Martin Geisler
tests: added a short description to issue numbers...
r12399 Issue1827: Hooks Update & Commit not completely post operation
commit and update hooks should run after command completion
Nicolas Dumazet
tests: unify test-hook
r11793
$ echo '[hooks]' > .hg/hgrc
$ echo 'commit = hg id' >> .hg/hgrc
$ echo 'update = hg id' >> .hg/hgrc
$ echo bb > a
Martin Geisler
tests: remove unneeded -d flags...
r12156 $ hg ci -ma
223eafe2750c tip
Nicolas Dumazet
tests: unify test-hook
r11793 $ hg up 0
Martin Geisler
tests: remove unneeded -d flags...
r12156 cb9a9f314b8b
Nicolas Dumazet
tests: unify test-hook
r11793 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Idan Kamara
dispatch: propagate ui command options to the local ui (issue2523)...
r14601 make sure --verbose (and --quiet/--debug etc.) are propogated to the local ui
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