Show More
@@ -846,3 +846,12 b' def printbookmarks(ui, repo, **opts):' | |||
|
846 | 846 | |
|
847 | 847 | bmarks[bmark] = (n, prefix, label) |
|
848 | 848 | _printbookmarks(ui, repo, bmarks, **opts) |
|
849 | ||
|
850 | def preparehookargs(name, old, new): | |
|
851 | if new is None: | |
|
852 | new = '' | |
|
853 | if old is None: | |
|
854 | old = '' | |
|
855 | return {'bookmark': name, | |
|
856 | 'node': hex(new), | |
|
857 | 'oldnode': hex(old)} |
@@ -994,6 +994,18 b' be ``$HG_HOOKTYPE=incoming`` and ``$HG_H' | |||
|
994 | 994 | after the lock is released. See :hg:`help config.hooks.pretxnclose` for |
|
995 | 995 | details about available variables. |
|
996 | 996 | |
|
997 | ``txnclose-bookmark`` | |
|
998 | Run after any bookmark change has been committed. At this point, the | |
|
999 | transaction can no longer be rolled back. The hook will run after the lock | |
|
1000 | is released. | |
|
1001 | The name of the bookmark will be available in ``$HG_BOOKMARK``, the new | |
|
1002 | bookmark location will be available in ``$HG_NODE`` while the previous | |
|
1003 | location will be available in ``$HG_OLDNODE``. In case of a bookmark | |
|
1004 | creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE`` | |
|
1005 | will be empty. In addition, the reason for the transaction opening will be | |
|
1006 | in ``$HG_TXNNAME``, and a unique identifier for the transaction will be in | |
|
1007 | ``HG_TXNID``. | |
|
1008 | ||
|
997 | 1009 | ``txnabort`` |
|
998 | 1010 | Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose` |
|
999 | 1011 | for details about available variables. |
@@ -1280,10 +1280,19 b' class localrepository(object):' | |||
|
1280 | 1280 | # fixes the function accumulation. |
|
1281 | 1281 | hookargs = tr2.hookargs |
|
1282 | 1282 | |
|
1283 | def hook(): | |
|
1284 | reporef().hook('txnclose', throw=False, txnname=desc, | |
|
1283 | def hookfunc(): | |
|
1284 | repo = reporef() | |
|
1285 | if hook.hashook(repo.ui, 'txnclose-bookmark'): | |
|
1286 | bmchanges = sorted(tr.changes['bookmarks'].items()) | |
|
1287 | for name, (old, new) in bmchanges: | |
|
1288 | args = tr.hookargs.copy() | |
|
1289 | args.update(bookmarks.preparehookargs(name, old, new)) | |
|
1290 | repo.hook('txnclose-bookmark', throw=False, | |
|
1291 | txnname=desc, **pycompat.strkwargs(args)) | |
|
1292 | ||
|
1293 | repo.hook('txnclose', throw=False, txnname=desc, | |
|
1285 | 1294 |
|
|
1286 | reporef()._afterlock(hook) | |
|
1295 | reporef()._afterlock(hookfunc) | |
|
1287 | 1296 | tr.addfinalize('txnclose-hook', txnclosehook) |
|
1288 | 1297 | tr.addpostclose('warms-cache', self._buildcacheupdater(tr)) |
|
1289 | 1298 | def txnaborthook(tr2): |
@@ -9,6 +9,8 b'' | |||
|
9 | 9 | > stabilization=createmarkers,exchange |
|
10 | 10 | > EOF |
|
11 | 11 | |
|
12 | $ TESTHOOK='hooks.txnclose-bookmark.test=echo "test-hook-bookmark: $HG_BOOKMARK: $HG_OLDNODE -> $HG_NODE"' | |
|
13 | ||
|
12 | 14 | initialize |
|
13 | 15 | |
|
14 | 16 | $ hg init a |
@@ -30,7 +32,7 b' import bookmark by name' | |||
|
30 | 32 | $ hg book Y |
|
31 | 33 | $ hg book |
|
32 | 34 | * Y -1:000000000000 |
|
33 | $ hg pull ../a | |
|
35 | $ hg pull ../a --config "$TESTHOOK" | |
|
34 | 36 | pulling from ../a |
|
35 | 37 | requesting all changes |
|
36 | 38 | adding changesets |
@@ -41,6 +43,9 b' import bookmark by name' | |||
|
41 | 43 | updating bookmark Y |
|
42 | 44 | adding remote bookmark Z |
|
43 | 45 | new changesets 4e3505fd9583 |
|
46 | test-hook-bookmark: X: -> 4e3505fd95835d721066b76e75dbb8cc554d7f77 | |
|
47 | test-hook-bookmark: Y: 0000000000000000000000000000000000000000 -> 4e3505fd95835d721066b76e75dbb8cc554d7f77 | |
|
48 | test-hook-bookmark: Z: -> 4e3505fd95835d721066b76e75dbb8cc554d7f77 | |
|
44 | 49 | (run 'hg update' to get a working copy) |
|
45 | 50 | $ hg bookmarks |
|
46 | 51 | X 0:4e3505fd9583 |
@@ -94,10 +99,11 b' export bookmark by name' | |||
|
94 | 99 | delete a remote bookmark |
|
95 | 100 | |
|
96 | 101 | $ hg book -d W |
|
97 | $ hg push -B W ../a | |
|
102 | $ hg push -B W ../a --config "$TESTHOOK" | |
|
98 | 103 | pushing to ../a |
|
99 | 104 | searching for changes |
|
100 | 105 | no changes found |
|
106 | test-hook-bookmark: W: 0000000000000000000000000000000000000000 -> | |
|
101 | 107 | deleting remote bookmark W |
|
102 | 108 | [1] |
|
103 | 109 | |
@@ -165,7 +171,7 b' divergent bookmarks' | |||
|
165 | 171 | Z 1:0d2164f0ce0d |
|
166 | 172 | |
|
167 | 173 | $ cd ../b |
|
168 | $ hg up | |
|
174 | $ hg up --config | |
|
169 | 175 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
170 | 176 | updating bookmark foobar |
|
171 | 177 | $ echo c2 > f2 |
@@ -181,7 +187,7 b' divergent bookmarks' | |||
|
181 | 187 | foo -1:000000000000 |
|
182 | 188 | * foobar 1:9b140be10808 |
|
183 | 189 | |
|
184 | $ hg pull --config paths.foo=../a foo | |
|
190 | $ hg pull --config paths.foo=../a foo --config "$TESTHOOK" | |
|
185 | 191 | pulling from $TESTTMP/a (glob) |
|
186 | 192 | searching for changes |
|
187 | 193 | adding changesets |
@@ -192,6 +198,9 b' divergent bookmarks' | |||
|
192 | 198 | divergent bookmark X stored as X@foo |
|
193 | 199 | updating bookmark Z |
|
194 | 200 | new changesets 0d2164f0ce0d |
|
201 | test-hook-bookmark: @foo: -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c | |
|
202 | test-hook-bookmark: X@foo: -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c | |
|
203 | test-hook-bookmark: Z: 4e3505fd95835d721066b76e75dbb8cc554d7f77 -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c | |
|
195 | 204 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
196 | 205 | $ hg book |
|
197 | 206 | @ 1:9b140be10808 |
@@ -254,11 +263,13 b' explicit pull should overwrite the local' | |||
|
254 | 263 | $ hg update -r X |
|
255 | 264 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
256 | 265 | (activating bookmark X) |
|
257 | $ hg pull --config paths.foo=../a foo -B . | |
|
266 | $ hg pull --config paths.foo=../a foo -B . --config "$TESTHOOK" | |
|
258 | 267 | pulling from $TESTTMP/a (glob) |
|
259 | 268 | no changes found |
|
260 | 269 | divergent bookmark @ stored as @foo |
|
261 | 270 | importing bookmark X |
|
271 | test-hook-bookmark: @foo: 0d2164f0ce0d8f1d6f94351eba04b794909be66c -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c | |
|
272 | test-hook-bookmark: X: 9b140be1080824d768c5a4691a564088eede71f9 -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c | |
|
262 | 273 | |
|
263 | 274 | reinstall state for further testing: |
|
264 | 275 | |
@@ -283,13 +294,14 b' update a remote bookmark from a non-head' | |||
|
283 | 294 | $ hg ci -Am3 |
|
284 | 295 | adding f2 |
|
285 | 296 | created new head |
|
286 | $ hg push ../a | |
|
297 | $ hg push ../a --config "$TESTHOOK" | |
|
287 | 298 | pushing to ../a |
|
288 | 299 | searching for changes |
|
289 | 300 | adding changesets |
|
290 | 301 | adding manifests |
|
291 | 302 | adding file changes |
|
292 | 303 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
304 | test-hook-bookmark: Y: 4e3505fd95835d721066b76e75dbb8cc554d7f77 -> f6fc62dde3c0771e29704af56ba4d8af77abcc2f | |
|
293 | 305 | updating bookmark Y |
|
294 | 306 | $ hg -R ../a book |
|
295 | 307 | @ 1:0d2164f0ce0d |
@@ -314,7 +326,11 b' race conditions' | |||
|
314 | 326 | > echo committed in pull-race |
|
315 | 327 | > EOF |
|
316 | 328 | |
|
317 | $ hg clone -q http://localhost:$HGPORT/ pull-race2 | |
|
329 | $ hg clone -q http://localhost:$HGPORT/ pull-race2 --config "$TESTHOOK" | |
|
330 | test-hook-bookmark: @: -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c | |
|
331 | test-hook-bookmark: X: -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c | |
|
332 | test-hook-bookmark: Y: -> f6fc62dde3c0771e29704af56ba4d8af77abcc2f | |
|
333 | test-hook-bookmark: Z: -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c | |
|
318 | 334 | $ cd pull-race |
|
319 | 335 | $ hg up -q Y |
|
320 | 336 | $ echo c4 > f2 |
@@ -1,6 +1,9 b'' | |||
|
1 | ||
|
1 | 2 | $ hg init repo |
|
2 | 3 | $ cd repo |
|
3 | 4 | |
|
5 | $ TESTHOOK='hooks.txnclose-bookmark.test=echo "test-hook-bookmark: $HG_BOOKMARK: $HG_OLDNODE -> $HG_NODE"' | |
|
6 | ||
|
4 | 7 | no bookmarks |
|
5 | 8 | |
|
6 | 9 | $ hg bookmarks |
@@ -12,7 +15,8 b' no bookmarks' | |||
|
12 | 15 | |
|
13 | 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 | 21 | list bookmarks |
|
18 | 22 | |
@@ -27,7 +31,8 b' list bookmarks with color' | |||
|
27 | 31 | |
|
28 | 32 | $ echo a > a |
|
29 | 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 | 37 | bookmark X moved to rev 0 |
|
33 | 38 | |
@@ -47,7 +52,8 b' look up bookmark' | |||
|
47 | 52 | |
|
48 | 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 | 58 | bookmark rev -1 again |
|
53 | 59 | |
@@ -62,7 +68,8 b' list bookmarks' | |||
|
62 | 68 | |
|
63 | 69 | $ echo b > b |
|
64 | 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 | 74 |
$ |
|
68 | 75 | [ |
@@ -194,14 +201,17 b' force rename to existent bookmark' | |||
|
194 | 201 | rename bookmark using . |
|
195 | 202 | |
|
196 | 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 | 207 | $ hg bookmark |
|
199 | 208 | X2 1:925d80f479bb |
|
200 | 209 | Y 2:db815d6d32e6 |
|
201 | 210 | Z 0:f7b1eb17ad24 |
|
202 | 211 | * renamed 2:db815d6d32e6 |
|
203 | 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 | 216 | rename bookmark using . with no active bookmark |
|
207 | 217 | |
@@ -354,11 +364,13 b' bookmark with integer name' | |||
|
354 | 364 | [255] |
|
355 | 365 | |
|
356 | 366 | bookmark with a name that matches a node id |
|
357 | $ hg bookmark 925d80f479bb db815d6d32e6 | |
|
367 | $ hg bookmark 925d80f479bb db815d6d32e6 --config "$TESTHOOK" | |
|
358 | 368 | bookmark 925d80f479bb matches a changeset hash |
|
359 | 369 | (did you leave a -r out of an 'hg bookmark' command?) |
|
360 | 370 | bookmark db815d6d32e6 matches a changeset hash |
|
361 | 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 | 374 | $ hg bookmark -d 925d80f479bb |
|
363 | 375 | $ hg bookmark -d db815d6d32e6 |
|
364 | 376 | |
@@ -406,7 +418,8 b' incompatible options' | |||
|
406 | 418 | |
|
407 | 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 | 424 | force bookmark back to where it was, should deactivate it |
|
412 | 425 |
General Comments 0
You need to be logged in to leave comments.
Login now