tests/test-hook.t
author Sune Foldager <cryo@cyanite.org>
Mon, 13 Sep 2010 16:25:13 +0200
changeset 12278 c4c2ba553401
parent 12156 4c94b6d0fb1c
child 12316 4134686b83e1
permissions -rw-r--r--
merge with stable
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
     1
  $ cp "$TESTDIR"/printenv.py .
4286
949516072388 test-hook: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4085
diff changeset
     2
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
     3
# commit hooks can see env vars
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
     4
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
     5
  $ hg init a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
     6
  $ cd a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
     7
  $ echo "[hooks]" > .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
     8
  $ echo 'commit = unset HG_LOCAL HG_TAG; python ../printenv.py commit' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
     9
  $ echo 'commit.b = unset HG_LOCAL HG_TAG; python ../printenv.py commit.b' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    10
  $ echo 'precommit = unset HG_LOCAL HG_NODE HG_TAG; python ../printenv.py precommit' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    11
  $ echo 'pretxncommit = unset HG_LOCAL HG_TAG; python ../printenv.py pretxncommit' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    12
  $ echo 'pretxncommit.tip = hg -q tip' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    13
  $ echo 'pre-identify = python ../printenv.py pre-identify 1' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    14
  $ echo 'pre-cat = python ../printenv.py pre-cat' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    15
  $ echo 'post-cat = python ../printenv.py post-cat' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    16
  $ echo a > a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    17
  $ hg add a
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    18
  $ hg commit -m a
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    19
  precommit hook: HG_PARENT1=0000000000000000000000000000000000000000 
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    20
  pretxncommit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$HGTMP/test-hook.t/a 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    21
  0:cb9a9f314b8b
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    22
  commit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    23
  commit.b hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    24
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    25
  $ hg clone . ../b
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    26
  updating to branch default
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    27
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    28
  $ cd ../b
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    29
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    30
# changegroup hooks can see env vars
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    31
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    32
  $ echo '[hooks]' > .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    33
  $ echo 'prechangegroup = python ../printenv.py prechangegroup' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    34
  $ echo 'changegroup = python ../printenv.py changegroup' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    35
  $ echo 'incoming = python ../printenv.py incoming' >> .hg/hgrc
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    36
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    37
# pretxncommit and commit hooks can see both parents of merge
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    38
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    39
  $ cd ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    40
  $ echo b >> a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    41
  $ hg commit -m a1 -d "1 0"
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    42
  precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    43
  pretxncommit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$HGTMP/test-hook.t/a 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    44
  1:ab228980c14d
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    45
  commit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    46
  commit.b hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    47
  $ hg update -C 0
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    48
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    49
  $ echo b > b
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    50
  $ hg add b
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    51
  $ hg commit -m b -d '1 0'
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    52
  precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    53
  pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$HGTMP/test-hook.t/a 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    54
  2:ee9deb46ab31
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    55
  commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    56
  commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    57
  created new head
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    58
  $ hg merge 1
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    59
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    60
  (branch merge, don't forget to commit)
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    61
  $ hg commit -m merge -d '2 0'
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    62
  precommit hook: HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    63
  pretxncommit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$HGTMP/test-hook.t/a 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    64
  3:07f3376c1e65
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    65
  commit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    66
  commit.b hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd 
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    67
4630
e6d105a51ec7 dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents: 4368
diff changeset
    68
# test generic hooks
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    69
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    70
  $ hg id
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    71
  pre-identify hook: HG_ARGS=id HG_OPTS={'tags': None, 'rev': '', 'num': None, 'branch': None, 'id': None} HG_PATS=[] 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    72
  warning: pre-identify hook exited with status 1
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    73
  $ hg cat b
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    74
  pre-cat hook: HG_ARGS=cat b HG_OPTS={'rev': '', 'decode': None, 'exclude': [], 'output': '', 'include': []} HG_PATS=['b'] 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    75
  post-cat hook: HG_ARGS=cat b HG_OPTS={'rev': '', 'decode': None, 'exclude': [], 'output': '', 'include': []} HG_PATS=['b'] HG_RESULT=0 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    76
  b
4630
e6d105a51ec7 dispatch: add generic pre- and post-command hooks
Matt Mackall <mpm@selenic.com>
parents: 4368
diff changeset
    77
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    78
  $ cd ../b
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    79
  $ hg pull ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    80
  prechangegroup hook: HG_SOURCE=pull HG_URL=file: 
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    81
  changegroup hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_URL=file: 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    82
  incoming hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_URL=file: 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    83
  incoming hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_URL=file: 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    84
  incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_URL=file: 
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    85
  pulling from ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    86
  searching for changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    87
  adding changesets
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    88
  adding manifests
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    89
  adding file changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    90
  added 3 changesets with 2 changes to 2 files
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    91
  (run 'hg update' to get a working copy)
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    92
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
    93
# tag hooks can see env vars
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    94
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    95
  $ cd ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    96
  $ echo 'pretag = python ../printenv.py pretag' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    97
  $ echo 'tag = unset HG_PARENT1 HG_PARENT2; python ../printenv.py tag' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
    98
  $ hg tag -d '3 0' a
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
    99
  pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   100
  precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   101
  pretxncommit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$HGTMP/test-hook.t/a 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   102
  4:539e4b31b6dc
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   103
  commit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   104
  commit.b hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   105
  tag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a 
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   106
  $ hg tag -l la
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   107
  pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   108
  tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la 
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
   109
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
   110
# pretag hook can forbid tagging
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   111
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   112
  $ echo 'pretag.forbid = python ../printenv.py pretag.forbid 1' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   113
  $ hg tag -d '4 0' fa
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   114
  pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   115
  pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa 
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   116
  abort: pretag.forbid hook exited with status 1
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   117
  $ hg tag -l fla
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   118
  pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   119
  pretag.forbid hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla 
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   120
  abort: pretag.forbid hook exited with status 1
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
   121
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
   122
# pretxncommit hook can see changeset, can roll back txn, changeset
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
   123
# no more there after
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   124
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   125
  $ echo 'pretxncommit.forbid0 = hg tip -q' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   126
  $ echo 'pretxncommit.forbid1 = python ../printenv.py pretxncommit.forbid 1' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   127
  $ echo z > z
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   128
  $ hg add z
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   129
  $ hg -q tip
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   130
  4:539e4b31b6dc
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   131
  $ hg commit -m 'fail' -d '4 0'
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   132
  precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   133
  pretxncommit hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$HGTMP/test-hook.t/a 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   134
  5:6f611f8018c1
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   135
  5:6f611f8018c1
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   136
  pretxncommit.forbid hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$HGTMP/test-hook.t/a 
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   137
  transaction abort!
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   138
  rollback completed
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   139
  abort: pretxncommit.forbid1 hook exited with status 1
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   140
  $ hg -q tip
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   141
  4:539e4b31b6dc
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
   142
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
   143
# precommit hook can prevent commit
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   144
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   145
  $ echo 'precommit.forbid = python ../printenv.py precommit.forbid 1' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   146
  $ hg commit -m 'fail' -d '4 0'
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   147
  precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   148
  precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   149
  abort: precommit.forbid hook exited with status 1
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   150
  $ hg -q tip
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   151
  4:539e4b31b6dc
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
   152
2266
3f7692b0ff13 hooks: add preupdate and update hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2227
diff changeset
   153
# preupdate hook can prevent update
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   154
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   155
  $ echo 'preupdate = python ../printenv.py preupdate' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   156
  $ hg update 1
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   157
  preupdate hook: HG_PARENT1=ab228980c14d 
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   158
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
2266
3f7692b0ff13 hooks: add preupdate and update hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2227
diff changeset
   159
3f7692b0ff13 hooks: add preupdate and update hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2227
diff changeset
   160
# update hook
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   161
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   162
  $ echo 'update = python ../printenv.py update' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   163
  $ hg update
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   164
  preupdate hook: HG_PARENT1=539e4b31b6dc 
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   165
  update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc 
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   166
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
2266
3f7692b0ff13 hooks: add preupdate and update hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2227
diff changeset
   167
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
   168
# prechangegroup hook can prevent incoming changes
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   169
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   170
  $ cd ../b
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   171
  $ hg -q tip
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   172
  3:07f3376c1e65
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   173
  $ echo '[hooks]' > .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   174
  $ echo 'prechangegroup.forbid = python ../printenv.py prechangegroup.forbid 1' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   175
  $ hg pull ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   176
  prechangegroup.forbid hook: HG_SOURCE=pull HG_URL=file: 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   177
  pulling from ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   178
  searching for changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   179
  abort: prechangegroup.forbid hook exited with status 1
1734
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
   180
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
   181
# pretxnchangegroup hook can see incoming changes, can roll back txn,
9488d53233b5 tests for new hooks. fix things i found when writing tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1481
diff changeset
   182
# incoming changes no longer there after
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   183
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   184
  $ echo '[hooks]' > .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   185
  $ echo 'pretxnchangegroup.forbid0 = hg tip -q' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   186
  $ echo 'pretxnchangegroup.forbid1 = python ../printenv.py pretxnchangegroup.forbid 1' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   187
  $ hg pull ../a
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   188
  4:539e4b31b6dc
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   189
  pretxnchangegroup.forbid hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$HGTMP/test-hook.t/b HG_SOURCE=pull HG_URL=file: 
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   190
  pulling from ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   191
  searching for changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   192
  adding changesets
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   193
  adding manifests
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   194
  adding file changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   195
  added 1 changesets with 1 changes to 1 files
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   196
  transaction abort!
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   197
  rollback completed
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   198
  abort: pretxnchangegroup.forbid1 hook exited with status 1
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   199
  $ hg -q tip
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   200
  3:07f3376c1e65
1736
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
   201
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
   202
# outgoing hooks can see env vars
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   203
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   204
  $ rm .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   205
  $ echo '[hooks]' > ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   206
  $ echo 'preoutgoing = python ../printenv.py preoutgoing' >> ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   207
  $ echo 'outgoing = python ../printenv.py outgoing' >> ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   208
  $ hg pull ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   209
  preoutgoing hook: HG_SOURCE=pull 
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   210
  outgoing hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull 
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   211
  pulling from ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   212
  searching for changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   213
  adding changesets
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   214
  adding manifests
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   215
  adding file changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   216
  added 1 changesets with 1 changes to 1 files
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   217
  (run 'hg update' to get a working copy)
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   218
  $ hg rollback
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   219
  rolling back to revision 3 (undo pull)
1736
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
   220
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
   221
# preoutgoing hook can prevent outgoing changes
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   222
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   223
  $ echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   224
  $ hg pull ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   225
  preoutgoing hook: HG_SOURCE=pull 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   226
  preoutgoing.forbid hook: HG_SOURCE=pull 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   227
  pulling from ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   228
  searching for changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   229
  abort: preoutgoing.forbid hook exited with status 1
1736
50de0887bbcd add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1734
diff changeset
   230
8907
e9ef409e6399 Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents: 4659
diff changeset
   231
# outgoing hooks work for local clones
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   232
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   233
  $ cd ..
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   234
  $ echo '[hooks]' > a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   235
  $ echo 'preoutgoing = python ../printenv.py preoutgoing' >> a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   236
  $ echo 'outgoing = python ../printenv.py outgoing' >> a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   237
  $ hg clone a c
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   238
  preoutgoing hook: HG_SOURCE=clone 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   239
  outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   240
  updating to branch default
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   241
  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   242
  $ rm -rf c
8907
e9ef409e6399 Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents: 4659
diff changeset
   243
e9ef409e6399 Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents: 4659
diff changeset
   244
# preoutgoing hook can prevent outgoing changes for local clones
e9ef409e6399 Add (pre)outgoing hooks for local clones.
Fred Wulff <frew@cs.stanford.edu>
parents: 4659
diff changeset
   245
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   246
  $ echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   247
  $ hg clone a zzz
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   248
  preoutgoing hook: HG_SOURCE=clone 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   249
  preoutgoing.forbid hook: HG_SOURCE=clone 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   250
  abort: preoutgoing.forbid hook exited with status 1
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   251
  $ cd b
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   252
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   253
  $ cat > hooktests.py <<EOF
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   254
  > from mercurial import util
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   255
  > 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   256
  > uncallable = 0
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   257
  > 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   258
  > def printargs(args):
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   259
  >     args.pop('ui', None)
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   260
  >     args.pop('repo', None)
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   261
  >     a = list(args.items())
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   262
  >     a.sort()
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   263
  >     print 'hook args:'
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   264
  >     for k, v in a:
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   265
  >        print ' ', k, v
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   266
  > 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   267
  > def passhook(**args):
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   268
  >     printargs(args)
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   269
  > 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   270
  > def failhook(**args):
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   271
  >     printargs(args)
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   272
  >     return True
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   273
  > 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   274
  > class LocalException(Exception):
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   275
  >     pass
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   276
  > 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   277
  > def raisehook(**args):
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   278
  >     raise LocalException('exception from hook')
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   279
  > 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   280
  > def aborthook(**args):
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   281
  >     raise util.Abort('raise abort from hook')
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   282
  > 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   283
  > def brokenhook(**args):
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   284
  >     return 1 + {}
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   285
  > 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   286
  > class container:
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   287
  >     unreachable = 1
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   288
  > EOF
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   289
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   290
# test python hooks
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   291
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   292
  $ PYTHONPATH="`pwd`:$PYTHONPATH"
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   293
  $ export PYTHONPATH
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   294
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   295
  $ echo '[hooks]' > ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   296
  $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   297
  $ hg pull ../a 2>&1 | grep 'raised an exception'
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   298
  error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   299
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   300
  $ echo '[hooks]' > ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   301
  $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   302
  $ hg pull ../a 2>&1 | grep 'raised an exception'
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   303
  error: preoutgoing.raise hook raised an exception: exception from hook
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   304
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   305
  $ echo '[hooks]' > ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   306
  $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   307
  $ hg pull ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   308
  pulling from ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   309
  searching for changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   310
  error: preoutgoing.abort hook failed: raise abort from hook
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   311
  abort: raise abort from hook
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   312
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   313
  $ echo '[hooks]' > ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   314
  $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   315
  $ hg pull ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   316
  pulling from ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   317
  searching for changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   318
  hook args:
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   319
    hooktype preoutgoing
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   320
    source pull
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   321
  abort: preoutgoing.fail hook failed
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   322
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   323
  $ echo '[hooks]' > ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   324
  $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   325
  $ hg pull ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   326
  pulling from ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   327
  searching for changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   328
  abort: preoutgoing.uncallable hook is invalid ("hooktests.uncallable" is not callable)
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   329
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   330
  $ echo '[hooks]' > ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   331
  $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   332
  $ hg pull ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   333
  pulling from ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   334
  searching for changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   335
  abort: preoutgoing.nohook hook is invalid ("hooktests.nohook" is not defined)
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   336
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   337
  $ echo '[hooks]' > ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   338
  $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   339
  $ hg pull ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   340
  pulling from ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   341
  searching for changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   342
  abort: preoutgoing.nomodule hook is invalid ("nomodule" not in a module)
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   343
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   344
  $ echo '[hooks]' > ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   345
  $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   346
  $ hg pull ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   347
  pulling from ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   348
  searching for changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   349
  abort: preoutgoing.badmodule hook is invalid (import of "nomodule" failed)
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   350
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   351
  $ echo '[hooks]' > ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   352
  $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   353
  $ hg pull ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   354
  pulling from ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   355
  searching for changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   356
  abort: preoutgoing.unreachable hook is invalid (import of "hooktests.container" failed)
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   357
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   358
  $ echo '[hooks]' > ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   359
  $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   360
  $ hg pull ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   361
  pulling from ../a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   362
  searching for changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   363
  hook args:
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   364
    hooktype preoutgoing
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   365
    source pull
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   366
  adding changesets
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   367
  adding manifests
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   368
  adding file changes
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   369
  added 1 changesets with 1 changes to 1 files
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   370
  (run 'hg update' to get a working copy)
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   371
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   372
# make sure --traceback works
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   373
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   374
  $ echo '[hooks]' > .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   375
  $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
2155
ff255b41b4aa support hooks written in python.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
   376
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   377
  $ echo aa > a
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   378
  $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   379
  Traceback (most recent call last):
4070
961ccb615cf7 Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2673
diff changeset
   380
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   381
  $ cd ..
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   382
  $ hg init c
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   383
  $ cd c
4070
961ccb615cf7 Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2673
diff changeset
   384
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   385
  $ cat > hookext.py <<EOF
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   386
  > def autohook(**args):
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   387
  >     print "Automatically installed hook"
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   388
  > 
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   389
  > def reposetup(ui, repo):
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   390
  >     repo.ui.setconfig("hooks", "commit.auto", autohook)
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   391
  > EOF
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   392
  $ echo '[extensions]' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   393
  $ echo 'hookext = hookext.py' >> .hg/hgrc
4070
961ccb615cf7 Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2673
diff changeset
   394
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   395
  $ touch foo
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   396
  $ hg add foo
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   397
  $ hg ci -d '0 0' -m 'add foo'
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   398
  Automatically installed hook
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   399
  $ echo >> foo
11794
80c63b2a29a8 tests: remove useless sed in test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11793
diff changeset
   400
  $ hg ci --debug -d '0 0' -m 'change foo'
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   401
  foo
11794
80c63b2a29a8 tests: remove useless sed in test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11793
diff changeset
   402
  calling hook commit.auto: <function autohook at .*>
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   403
  Automatically installed hook
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   404
  committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
4070
961ccb615cf7 Handle functions as the value of a hooks.<name> config variable
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2673
diff changeset
   405
11794
80c63b2a29a8 tests: remove useless sed in test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11793
diff changeset
   406
  $ hg showconfig hooks
80c63b2a29a8 tests: remove useless sed in test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11793
diff changeset
   407
  hooks.commit.auto=<function autohook at .*>
4085
719488a98ebe Fix hg showconfig traceback with values that aren't strings
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4070
diff changeset
   408
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   409
# test python hook configured with python:[file]:[hook] syntax
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   410
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   411
  $ cd ..
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   412
  $ mkdir d
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   413
  $ cd d
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   414
  $ hg init repo
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   415
  $ mkdir hooks
9014
87c05a78e588 test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents: 8907
diff changeset
   416
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   417
  $ cd hooks
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   418
  $ cat > testhooks.py <<EOF
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   419
  > def testhook(**args):
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   420
  >     print 'hook works'
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   421
  > EOF
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   422
  $ echo '[hooks]' > ../repo/.hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   423
  $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
9014
87c05a78e588 test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents: 8907
diff changeset
   424
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   425
  $ cd ../repo
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   426
  $ hg commit -d '0 0'
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   427
  hook works
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   428
  nothing changed
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   429
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   430
  $ cd ../../b
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   431
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   432
# make sure --traceback works on hook import failure
9014
87c05a78e588 test python hook configured with python:[file]:[hook] syntax
Henri Wiechers <hwiechers@gmail.com>
parents: 8907
diff changeset
   433
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   434
  $ cat > importfail.py <<EOF
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   435
  > import somebogusmodule
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   436
  > # dereference something in the module to force demandimport to load it
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   437
  > somebogusmodule.whatever
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   438
  > EOF
9851
9e7b2c49d25d Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents: 9014
diff changeset
   439
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   440
  $ echo '[hooks]' > .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   441
  $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
9851
9e7b2c49d25d Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents: 9014
diff changeset
   442
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   443
  $ echo a >> a
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   444
  $ hg --traceback commit -ma 2>&1 | egrep '^(exception|Traceback|ImportError)'
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   445
  exception from first failed import attempt:
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   446
  Traceback (most recent call last):
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   447
  ImportError: No module named somebogusmodule
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   448
  exception from second failed import attempt:
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   449
  Traceback (most recent call last):
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   450
  ImportError: No module named hgext_importfail
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   451
  Traceback (most recent call last):
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   452
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   453
# commit and update hooks should run after command completion (issue 1827)
10492
0e64d814d7d0 run commit and update hooks after command completion (issue1827)
Sune Foldager <cryo@cyanite.org>
parents: 10079
diff changeset
   454
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   455
  $ echo '[hooks]' > .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   456
  $ echo 'commit = hg id' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   457
  $ echo 'update = hg id' >> .hg/hgrc
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   458
  $ echo bb > a
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   459
  $ hg ci -ma
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   460
  223eafe2750c tip
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   461
  $ hg up 0
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 11794
diff changeset
   462
  cb9a9f314b8b
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   463
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
9851
9e7b2c49d25d Make it possible to debug failed hook imports via use of --traceback
Bryan O'Sullivan <bos@serpentine.com>
parents: 9014
diff changeset
   464
11793
a03ce716495d tests: unify test-hook
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10492
diff changeset
   465
  $ exit 0