comparison tests/test-bookmarks.t @ 34708:ee5f0d047b41

bookmark: add a dedicated txnclose-bookmark hook The new 'txnclose-bookmark' hook expose the bookmark movement information stored in 'tr.changes['bookmarks]'. To provide a simple and straightforward hook API to the users, we introduce a new hook called for each bookmark touched. Since a transaction can affect multiple bookmarks, updating the existing 'txnclose' hook to expose that information would be more complex. The data for all moves might not fit in environment variables and iterations over each move would be cumbersome. So the introduction of a new dedicated hook is preferred in this changeset. This does not exclude the addition to the full bookmark information to the existing 'txnclose' in the future to help write more complex hooks.
author Boris Feld <boris.feld@octobus.net>
date Tue, 10 Oct 2017 17:53:42 +0200
parents eb586ed5d8ce
children c212947273a7
comparison
equal deleted inserted replaced
34707:6cd8d8203204 34708:ee5f0d047b41
1
1 $ hg init repo 2 $ hg init repo
2 $ cd repo 3 $ cd repo
4
5 $ TESTHOOK='hooks.txnclose-bookmark.test=echo "test-hook-bookmark: $HG_BOOKMARK: $HG_OLDNODE -> $HG_NODE"'
3 6
4 no bookmarks 7 no bookmarks
5 8
6 $ hg bookmarks 9 $ hg bookmarks
7 no bookmarks set 10 no bookmarks set
10 [ 13 [
11 ] 14 ]
12 15
13 bookmark rev -1 16 bookmark rev -1
14 17
15 $ hg bookmark X 18 $ hg bookmark X --config "$TESTHOOK"
19 test-hook-bookmark: X: -> 0000000000000000000000000000000000000000
16 20
17 list bookmarks 21 list bookmarks
18 22
19 $ hg bookmarks 23 $ hg bookmarks
20 * X -1:000000000000 24 * X -1:000000000000
25 > bookmarks --color=always 29 > bookmarks --color=always
26 \x1b[0;32m * \x1b[0m\x1b[0;32mX\x1b[0m\x1b[0;32m -1:000000000000\x1b[0m (esc) 30 \x1b[0;32m * \x1b[0m\x1b[0;32mX\x1b[0m\x1b[0;32m -1:000000000000\x1b[0m (esc)
27 31
28 $ echo a > a 32 $ echo a > a
29 $ hg add a 33 $ hg add a
30 $ hg commit -m 0 34 $ hg commit -m 0 --config "$TESTHOOK"
35 test-hook-bookmark: X: 0000000000000000000000000000000000000000 -> f7b1eb17ad24730a1651fccd46c43826d1bbc2ac
31 36
32 bookmark X moved to rev 0 37 bookmark X moved to rev 0
33 38
34 $ hg bookmarks 39 $ hg bookmarks
35 * X 0:f7b1eb17ad24 40 * X 0:f7b1eb17ad24
45 summary: 0 50 summary: 0
46 51
47 52
48 second bookmark for rev 0, command should work even with ui.strict on 53 second bookmark for rev 0, command should work even with ui.strict on
49 54
50 $ hg --config ui.strict=1 bookmark X2 55 $ hg --config ui.strict=1 bookmark X2 --config "$TESTHOOK"
56 test-hook-bookmark: X2: -> f7b1eb17ad24730a1651fccd46c43826d1bbc2ac
51 57
52 bookmark rev -1 again 58 bookmark rev -1 again
53 59
54 $ hg bookmark -r null Y 60 $ hg bookmark -r null Y
55 61
60 * X2 0:f7b1eb17ad24 66 * X2 0:f7b1eb17ad24
61 Y -1:000000000000 67 Y -1:000000000000
62 68
63 $ echo b > b 69 $ echo b > b
64 $ hg add b 70 $ hg add b
65 $ hg commit -m 1 71 $ hg commit -m 1 --config "$TESTHOOK"
72 test-hook-bookmark: X2: f7b1eb17ad24730a1651fccd46c43826d1bbc2ac -> 925d80f479bb026b0fb3deb27503780b13f74123
66 73
67 $ hg bookmarks -Tjson 74 $ hg bookmarks -Tjson
68 [ 75 [
69 { 76 {
70 "active": false, 77 "active": false,
192 $ hg bookmark -f -m X Y 199 $ hg bookmark -f -m X Y
193 200
194 rename bookmark using . 201 rename bookmark using .
195 202
196 $ hg book rename-me 203 $ hg book rename-me
197 $ hg book -m . renamed 204 $ hg book -m . renamed --config "$TESTHOOK"
205 test-hook-bookmark: rename-me: db815d6d32e69058eadefc8cffbad37675707975 ->
206 test-hook-bookmark: renamed: -> db815d6d32e69058eadefc8cffbad37675707975
198 $ hg bookmark 207 $ hg bookmark
199 X2 1:925d80f479bb 208 X2 1:925d80f479bb
200 Y 2:db815d6d32e6 209 Y 2:db815d6d32e6
201 Z 0:f7b1eb17ad24 210 Z 0:f7b1eb17ad24
202 * renamed 2:db815d6d32e6 211 * renamed 2:db815d6d32e6
203 $ hg up -q Y 212 $ hg up -q Y
204 $ hg book -d renamed 213 $ hg book -d renamed --config "$TESTHOOK"
214 test-hook-bookmark: renamed: db815d6d32e69058eadefc8cffbad37675707975 ->
205 215
206 rename bookmark using . with no active bookmark 216 rename bookmark using . with no active bookmark
207 217
208 $ hg book rename-me 218 $ hg book rename-me
209 $ hg book -i rename-me 219 $ hg book -i rename-me
352 $ hg bookmark 10 362 $ hg bookmark 10
353 abort: cannot use an integer as a name 363 abort: cannot use an integer as a name
354 [255] 364 [255]
355 365
356 bookmark with a name that matches a node id 366 bookmark with a name that matches a node id
357 $ hg bookmark 925d80f479bb db815d6d32e6 367 $ hg bookmark 925d80f479bb db815d6d32e6 --config "$TESTHOOK"
358 bookmark 925d80f479bb matches a changeset hash 368 bookmark 925d80f479bb matches a changeset hash
359 (did you leave a -r out of an 'hg bookmark' command?) 369 (did you leave a -r out of an 'hg bookmark' command?)
360 bookmark db815d6d32e6 matches a changeset hash 370 bookmark db815d6d32e6 matches a changeset hash
361 (did you leave a -r out of an 'hg bookmark' command?) 371 (did you leave a -r out of an 'hg bookmark' command?)
372 test-hook-bookmark: 925d80f479bb: -> db815d6d32e69058eadefc8cffbad37675707975
373 test-hook-bookmark: db815d6d32e6: -> db815d6d32e69058eadefc8cffbad37675707975
362 $ hg bookmark -d 925d80f479bb 374 $ hg bookmark -d 925d80f479bb
363 $ hg bookmark -d db815d6d32e6 375 $ hg bookmark -d db815d6d32e6
364 376
365 $ cd .. 377 $ cd ..
366 378
404 abort: --rev is incompatible with --rename 416 abort: --rev is incompatible with --rename
405 [255] 417 [255]
406 418
407 force bookmark with existing name 419 force bookmark with existing name
408 420
409 $ hg bookmark -f X2 421 $ hg bookmark -f X2 --config "$TESTHOOK"
422 test-hook-bookmark: X2: 925d80f479bb026b0fb3deb27503780b13f74123 -> db815d6d32e69058eadefc8cffbad37675707975
410 423
411 force bookmark back to where it was, should deactivate it 424 force bookmark back to where it was, should deactivate it
412 425
413 $ hg bookmark -fr1 X2 426 $ hg bookmark -fr1 X2
414 $ hg bookmarks 427 $ hg bookmarks