# HG changeset patch # User Pierre-Yves David # Date 2019-02-09 22:01:30 # Node ID 94faa2e840941d67b025784e078b5f66536dab05 # Parent c1017bceb6eca60b1e77432aaee837f66e1ba421 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). diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1818,7 +1818,6 @@ class localrepository(object): 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 @@ class localrepository(object): 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 @@ class localrepository(object): 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 @@ class localrepository(object): 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 @@ class localrepository(object): 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 @@ class localrepository(object): 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 diff --git a/tests/test-bundle.t b/tests/test-bundle.t --- a/tests/test-bundle.t +++ b/tests/test-bundle.t @@ -240,6 +240,8 @@ hg -R bundle://../full.hg verify 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 @@ Pull full.hg into empty again (using -R; 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) diff --git a/tests/test-bundle2-multiple-changegroups.t b/tests/test-bundle2-multiple-changegroups.t --- a/tests/test-bundle2-multiple-changegroups.t +++ b/tests/test-bundle2-multiple-changegroups.t @@ -88,6 +88,8 @@ Pull the new commits in the clone 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 @@ Pull the new commits in the clone 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 @@ Pull the new commits in the clone 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 @@ Pull the new commits in the clone 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 @@ Pull the new commits in the clone 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 @@ Pull the new commits in the clone 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 @@ pullop.cgresult 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 @@ pullop.cgresult 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 @@ pullop.cgresult 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 @@ pullop.cgresult 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 @@ pullop.cgresult 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 @@ pullop.cgresult 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 @@ pullop.cgresult 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 @@ pullop.cgresult 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 @@ pullop.cgresult 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 @@ pullop.cgresult 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 @@ pullop.cgresult 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 @@ pullop.cgresult 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 @@ pullop.cgresult 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 @@ pullop.cgresult 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 @@ pullop.cgresult 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 diff --git a/tests/test-hook.t b/tests/test-hook.t --- a/tests/test-hook.t +++ b/tests/test-hook.t @@ -252,6 +252,8 @@ test generic hooks 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 @@ test generic hooks 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 @@ test generic hooks 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 @@ test generic hooks 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 @@ test generic hooks 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 @@ pushkey hook 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 @@ test that prepushkey can prevent incomin 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 @@ prechangegroup hook can prevent incoming 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 @@ incoming changes no longer there after 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! diff --git a/tests/test-http-bundle1.t b/tests/test-http-bundle1.t --- a/tests/test-http-bundle1.t +++ b/tests/test-http-bundle1.t @@ -167,6 +167,8 @@ pull 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) diff --git a/tests/test-http.t b/tests/test-http.t --- a/tests/test-http.t +++ b/tests/test-http.t @@ -156,6 +156,8 @@ pull 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) diff --git a/tests/test-https.t b/tests/test-https.t --- a/tests/test-https.t +++ b/tests/test-https.t @@ -232,6 +232,8 @@ pull without cacert 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) diff --git a/tests/test-push-http.t b/tests/test-push-http.t --- a/tests/test-push-http.t +++ b/tests/test-push-http.t @@ -101,6 +101,8 @@ expect success 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 @@ expect success 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 @@ expect success 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 @@ expect success, server lacks the httphea 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 @@ expect success, server lacks the unbundl 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 @@ has no parameter 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 @@ and fails the entire push. 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 @@ We don't need to test bundle1 because it 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 @@ Now do a variant of the above, except on 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 @@ Make phases updates work 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 diff --git a/tests/test-ssh-bundle1.t b/tests/test-ssh-bundle1.t --- a/tests/test-ssh-bundle1.t +++ b/tests/test-ssh-bundle1.t @@ -520,6 +520,8 @@ debug output 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 @@ debug output 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 @@ debug output 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 diff --git a/tests/test-ssh.t b/tests/test-ssh.t --- a/tests/test-ssh.t +++ b/tests/test-ssh.t @@ -570,6 +570,7 @@ debug output 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 @@ debug output 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 @@ debug output 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 @@ debug output 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 diff --git a/tests/test-static-http.t b/tests/test-static-http.t --- a/tests/test-static-http.t +++ b/tests/test-static-http.t @@ -73,6 +73,8 @@ check for HTTP opener failures when cach 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)