Mercurial > hg
changeset 41896:94faa2e84094
transaction: include txnname in the hookargs dictionary
There is no reason to not include the txnname alongside the txnid in all case.
The python hooks already have them, so aligning the the shell hooks seems it
could be useful in the future.
(I don't have a strong opinion about this, we can also decide to never align the
python and shell hooks and this and I'll drop this patch).
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 09 Feb 2019 23:01:30 +0100 |
parents | c1017bceb6ec |
children | c340a8ac7ef3 |
files | mercurial/localrepo.py tests/test-bundle.t tests/test-bundle2-multiple-changegroups.t tests/test-hook.t tests/test-http-bundle1.t tests/test-http.t tests/test-https.t tests/test-push-http.t tests/test-ssh-bundle1.t tests/test-ssh.t tests/test-static-http.t |
diffstat | 11 files changed, 102 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Fri Mar 08 00:00:44 2019 +0100 +++ b/mercurial/localrepo.py Sat Feb 09 23:01:30 2019 +0100 @@ -1818,7 +1818,6 @@ args = tr.hookargs.copy() args.update(bookmarks.preparehookargs(name, old, new)) repo.hook('pretxnclose-bookmark', throw=True, - txnname=desc, **pycompat.strkwargs(args)) if hook.hashook(repo.ui, 'pretxnclose-phase'): cl = repo.unfiltered().changelog @@ -1826,11 +1825,11 @@ args = tr.hookargs.copy() node = hex(cl.node(rev)) args.update(phases.preparehookargs(node, old, new)) - repo.hook('pretxnclose-phase', throw=True, txnname=desc, + repo.hook('pretxnclose-phase', throw=True, **pycompat.strkwargs(args)) repo.hook('pretxnclose', throw=True, - txnname=desc, **pycompat.strkwargs(tr.hookargs)) + **pycompat.strkwargs(tr.hookargs)) def releasefn(tr, success): repo = reporef() if success: @@ -1864,6 +1863,7 @@ tr.changes['bookmarks'] = {} tr.hookargs['txnid'] = txnid + tr.hookargs['txnname'] = desc # note: writing the fncache only during finalize mean that the file is # outdated when running hooks. As fncache is used for streaming clone, # this is not expected to break anything that happen during the hooks. @@ -1885,7 +1885,7 @@ args = tr.hookargs.copy() args.update(bookmarks.preparehookargs(name, old, new)) repo.hook('txnclose-bookmark', throw=False, - txnname=desc, **pycompat.strkwargs(args)) + **pycompat.strkwargs(args)) if hook.hashook(repo.ui, 'txnclose-phase'): cl = repo.unfiltered().changelog @@ -1894,10 +1894,10 @@ args = tr.hookargs.copy() node = hex(cl.node(rev)) args.update(phases.preparehookargs(node, old, new)) - repo.hook('txnclose-phase', throw=False, txnname=desc, + repo.hook('txnclose-phase', throw=False, **pycompat.strkwargs(args)) - repo.hook('txnclose', throw=False, txnname=desc, + repo.hook('txnclose', throw=False, **pycompat.strkwargs(hookargs)) reporef()._afterlock(hookfunc) tr.addfinalize('txnclose-hook', txnclosehook) @@ -1909,7 +1909,7 @@ def txnaborthook(tr2): """To be run if transaction is aborted """ - reporef().hook('txnabort', throw=False, txnname=desc, + reporef().hook('txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)) tr.addabort('txnabort-hook', txnaborthook) # avoid eager cache invalidation. in-memory data should be identical
--- a/tests/test-bundle.t Fri Mar 08 00:00:44 2019 +0100 +++ b/tests/test-bundle.t Sat Feb 09 23:01:30 2019 +0100 @@ -240,6 +240,8 @@ HG_NODE_LAST=aa35859c02ea8bd48da5da68cd2740ac71afcbaf HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + bundle:../full.hg HG_URL=bundle:../full.hg (no-msys !) HG_URL=bundle;../full.hg (msys !) @@ -272,6 +274,8 @@ HG_NODE_LAST=aa35859c02ea8bd48da5da68cd2740ac71afcbaf HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + bundle:empty+full.hg HG_URL=bundle:empty+full.hg (run 'hg heads' to see heads, 'hg merge' to merge)
--- a/tests/test-bundle2-multiple-changegroups.t Fri Mar 08 00:00:44 2019 +0100 +++ b/tests/test-bundle2-multiple-changegroups.t Sat Feb 09 23:01:30 2019 +0100 @@ -88,6 +88,8 @@ HG_PENDING=$TESTTMP/clone HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo remote: changegroup2 @@ -103,6 +105,8 @@ HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo new changesets 27547f69f254:f838bfaca5c7 @@ -112,6 +116,8 @@ HG_NODE_LAST=27547f69f25460a52fff66ad004e58da7ad3fb56 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo incoming hook: HG_HOOKNAME=incoming @@ -119,6 +125,8 @@ HG_NODE=27547f69f25460a52fff66ad004e58da7ad3fb56 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo changegroup hook: HG_HOOKNAME=changegroup @@ -128,6 +136,8 @@ HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo incoming hook: HG_HOOKNAME=incoming @@ -136,6 +146,8 @@ HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo pullop.cgresult is 1 @@ -204,6 +216,8 @@ HG_PENDING=$TESTTMP/clone HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo remote: changegroup2 @@ -219,6 +233,8 @@ HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo new changesets b3325c91a4d9:5cd59d311f65 @@ -228,6 +244,8 @@ HG_NODE_LAST=8a5212ebc8527f9fb821601504794e3eb11a1ed3 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo incoming hook: HG_HOOKNAME=incoming @@ -235,6 +253,8 @@ HG_NODE=b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo incoming hook: HG_HOOKNAME=incoming @@ -242,6 +262,8 @@ HG_NODE=8a5212ebc8527f9fb821601504794e3eb11a1ed3 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo changegroup hook: HG_HOOKNAME=changegroup @@ -251,6 +273,8 @@ HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo incoming hook: HG_HOOKNAME=incoming @@ -259,6 +283,8 @@ HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo incoming hook: HG_HOOKNAME=incoming @@ -267,6 +293,8 @@ HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo incoming hook: HG_HOOKNAME=incoming @@ -275,6 +303,8 @@ HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo pullop.cgresult is 3 @@ -343,6 +373,8 @@ HG_PENDING=$TESTTMP/clone HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo remote: changegroup2 @@ -358,6 +390,8 @@ HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo new changesets 71bd7b46de72:9d18e5bd9ab0 @@ -367,6 +401,8 @@ HG_NODE_LAST=71bd7b46de72e69a32455bf88d04757d542e6cf4 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo incoming hook: HG_HOOKNAME=incoming @@ -374,6 +410,8 @@ HG_NODE=71bd7b46de72e69a32455bf88d04757d542e6cf4 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo changegroup hook: HG_HOOKNAME=changegroup @@ -383,6 +421,8 @@ HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo incoming hook: HG_HOOKNAME=incoming @@ -391,6 +431,8 @@ HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/repo (glob) HG_URL=file:$TESTTMP/repo pullop.cgresult is -2
--- a/tests/test-hook.t Fri Mar 08 00:00:44 2019 +0100 +++ b/tests/test-hook.t Sat Feb 09 23:01:30 2019 +0100 @@ -252,6 +252,8 @@ HG_HOOKTYPE=prechangegroup HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/a (glob) HG_URL=file:$TESTTMP/a adding changesets @@ -265,6 +267,8 @@ HG_NODE_LAST=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/a (glob) HG_URL=file:$TESTTMP/a incoming hook: HG_HOOKNAME=incoming @@ -272,6 +276,8 @@ HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/a (glob) HG_URL=file:$TESTTMP/a incoming hook: HG_HOOKNAME=incoming @@ -279,6 +285,8 @@ HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/a (glob) HG_URL=file:$TESTTMP/a incoming hook: HG_HOOKNAME=incoming @@ -286,6 +294,8 @@ HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/a (glob) HG_URL=file:$TESTTMP/a (run 'hg update' to get a working copy) @@ -543,6 +553,7 @@ HG_PUSHKEYCOMPAT=1 HG_SOURCE=push HG_TXNID=TXN:$ID$ + HG_TXNNAME=push HG_URL=file:$TESTTMP/a txnclose hook: HG_BOOKMARK_MOVED=1 @@ -629,6 +640,7 @@ HG_PUSHKEYCOMPAT=1 HG_SOURCE=push HG_TXNID=TXN:$ID$ + HG_TXNNAME=push HG_URL=file:$TESTTMP/a abort: prepushkey hook exited with status 1 @@ -687,6 +699,8 @@ HG_HOOKTYPE=prechangegroup HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/a (glob) HG_URL=file:$TESTTMP/a abort: prechangegroup.forbid hook exited with status 1 @@ -715,6 +729,8 @@ HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + file:/*/$TESTTMP/a (glob) HG_URL=file:$TESTTMP/a transaction abort!
--- a/tests/test-http-bundle1.t Fri Mar 08 00:00:44 2019 +0100 +++ b/tests/test-http-bundle1.t Sat Feb 09 23:01:30 2019 +0100 @@ -167,6 +167,8 @@ HG_NODE_LAST=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + http://localhost:$HGPORT1/ HG_URL=http://localhost:$HGPORT1/ (run 'hg update' to get a working copy)
--- a/tests/test-http.t Fri Mar 08 00:00:44 2019 +0100 +++ b/tests/test-http.t Sat Feb 09 23:01:30 2019 +0100 @@ -156,6 +156,8 @@ HG_NODE_LAST=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + http://localhost:$HGPORT1/ HG_URL=http://localhost:$HGPORT1/ (run 'hg update' to get a working copy)
--- a/tests/test-https.t Fri Mar 08 00:00:44 2019 +0100 +++ b/tests/test-https.t Sat Feb 09 23:01:30 2019 +0100 @@ -232,6 +232,8 @@ HG_NODE_LAST=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + https://localhost:$HGPORT/ HG_URL=https://localhost:$HGPORT/ (run 'hg update' to get a working copy)
--- a/tests/test-push-http.t Fri Mar 08 00:00:44 2019 +0100 +++ b/tests/test-push-http.t Sat Feb 09 23:01:30 2019 +0100 @@ -101,6 +101,8 @@ remote: HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 remote: HG_SOURCE=serve remote: HG_TXNID=TXN:$ID$ + remote: HG_TXNNAME=serve + remote: remote:http:$LOCALIP: (glob) remote: HG_URL=remote:http:$LOCALIP: (glob) remote: % serve errors @@ -128,6 +130,8 @@ remote: HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 remote: HG_SOURCE=serve remote: HG_TXNID=TXN:$ID$ + remote: HG_TXNNAME=serve + remote: remote:http:$LOCALIP: (glob) remote: HG_URL=remote:http:$LOCALIP: (glob) remote: % serve errors @@ -159,6 +163,7 @@ remote: HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 remote: HG_SOURCE=serve remote: HG_TXNID=TXN:$ID$ + remote: HG_TXNNAME=serve remote: HG_URL=remote:http:$LOCALIP: (glob) remote: % serve errors @@ -187,6 +192,8 @@ remote: HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 remote: HG_SOURCE=serve remote: HG_TXNID=TXN:$ID$ + remote: HG_TXNNAME=serve + remote: remote:http:$LOCALIP: (glob) (no-bundle2 !) remote: HG_URL=remote:http:$LOCALIP: (glob) remote: % serve errors @@ -214,6 +221,8 @@ remote: HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 remote: HG_SOURCE=serve remote: HG_TXNID=TXN:$ID$ + remote: HG_TXNNAME=serve + remote: remote:http:$LOCALIP: (glob) (no-bundle2 !) remote: HG_URL=remote:http:$LOCALIP: (glob) remote: % serve errors @@ -253,6 +262,8 @@ remote: HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 remote: HG_SOURCE=serve remote: HG_TXNID=TXN:$ID$ + remote: HG_TXNNAME=serve + remote: remote:http:$LOCALIP: (glob) (no-bundle2 !) remote: HG_URL=remote:http:$LOCALIP: (glob) remote: % serve errors @@ -312,6 +323,7 @@ remote: HG_PHASES_MOVED=1 remote: HG_SOURCE=serve remote: HG_TXNID=TXN:$ID$ + remote: HG_TXNNAME=serve remote: HG_URL=remote:http:$LOCALIP: (glob) remote: remote: pushkey-abort: prepushkey hook exited with status 1 @@ -353,6 +365,7 @@ remote: HG_PHASES_MOVED=1 remote: HG_SOURCE=serve remote: HG_TXNID=TXN:$ID$ + remote: HG_TXNNAME=serve remote: HG_URL=remote:http:$LOCALIP: (glob) remote: % serve errors @@ -411,6 +424,7 @@ remote: HG_PHASES_MOVED=1 remote: HG_SOURCE=serve remote: HG_TXNID=TXN:$ID$ + remote: HG_TXNNAME=serve remote: HG_URL=remote:http:$LOCALIP: (glob) remote: remote: pushkey-abort: prepushkey hook exited with status 1 @@ -465,6 +479,7 @@ remote: HG_PHASES_MOVED=1 remote: HG_SOURCE=serve remote: HG_TXNID=TXN:$ID$ + remote: HG_TXNNAME=serve remote: HG_URL=remote:http:$LOCALIP: (glob) remote: % serve errors
--- a/tests/test-ssh-bundle1.t Fri Mar 08 00:00:44 2019 +0100 +++ b/tests/test-ssh-bundle1.t Sat Feb 09 23:01:30 2019 +0100 @@ -520,6 +520,8 @@ HG_NODE_LAST=a28a9d1a809cab7d4e2fde4bee738a9ede948b60 HG_SOURCE=serve HG_TXNID=TXN:$ID$ + HG_TXNNAME=serve + remote:ssh:$LOCALIP HG_URL=remote:ssh:$LOCALIP Got arguments 1:user@dummy 2:hg -R remote serve --stdio @@ -537,6 +539,8 @@ HG_NODE_LAST=1383141674ec756a6056f6a9097618482fe0f4a6 HG_SOURCE=serve HG_TXNID=TXN:$ID$ + HG_TXNNAME=serve + remote:ssh:$LOCALIP HG_URL=remote:ssh:$LOCALIP Got arguments 1:user@dummy 2:hg -R remote serve --stdio @@ -552,6 +556,8 @@ HG_NODE_LAST=65c38f4125f9602c8db4af56530cc221d93b8ef8 HG_SOURCE=serve HG_TXNID=TXN:$ID$ + HG_TXNNAME=serve + remote:ssh:$LOCALIP HG_URL=remote:ssh:$LOCALIP Got arguments 1:user@dummy 2:hg -R remote serve --stdio
--- a/tests/test-ssh.t Fri Mar 08 00:00:44 2019 +0100 +++ b/tests/test-ssh.t Sat Feb 09 23:01:30 2019 +0100 @@ -570,6 +570,7 @@ HG_NODE_LAST=a28a9d1a809cab7d4e2fde4bee738a9ede948b60 HG_SOURCE=serve HG_TXNID=TXN:$ID$ + HG_TXNNAME=serve HG_URL=remote:ssh:$LOCALIP Got arguments 1:user@dummy 2:hg -R remote serve --stdio @@ -588,6 +589,7 @@ HG_NODE_LAST=1383141674ec756a6056f6a9097618482fe0f4a6 HG_SOURCE=serve HG_TXNID=TXN:$ID$ + HG_TXNNAME=serve HG_URL=remote:ssh:$LOCALIP Got arguments 1:user@dummy 2:chg -R remote serve --stdio (chg !) @@ -598,6 +600,7 @@ HG_NODE_LAST=1383141674ec756a6056f6a9097618482fe0f4a6 (chg !) HG_SOURCE=serve (chg !) HG_TXNID=TXN:$ID$ (chg !) + HG_TXNNAME=serve (chg !) HG_URL=remote:ssh:$LOCALIP (chg !) (chg !) Got arguments 1:user@dummy 2:hg -R remote serve --stdio @@ -614,6 +617,7 @@ HG_NODE_LAST=65c38f4125f9602c8db4af56530cc221d93b8ef8 HG_SOURCE=serve HG_TXNID=TXN:$ID$ + HG_TXNNAME=serve HG_URL=remote:ssh:$LOCALIP Got arguments 1:user@dummy 2:hg -R remote serve --stdio
--- a/tests/test-static-http.t Fri Mar 08 00:00:44 2019 +0100 +++ b/tests/test-static-http.t Sat Feb 09 23:01:30 2019 +0100 @@ -73,6 +73,8 @@ HG_NODE_LAST=4ac2e3648604439c580c69b09ec9d93a88d93432 HG_SOURCE=pull HG_TXNID=TXN:$ID$ + HG_TXNNAME=pull + http://localhost:$HGPORT/remote HG_URL=http://localhost:$HGPORT/remote (run 'hg update' to get a working copy)