Mercurial > hg
changeset 25502:bd41c19383db
phases: abort the whole push if phases fail to update (BC)
When using bundle2, the phase pushkey parts are now made mandatory. As a
result, failure to update the bookmark server side will result in the transaction
being aborted.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 27 May 2015 22:25:51 -0700 |
parents | a99fee62611d |
children | 1b7853a1f04e |
files | mercurial/exchange.py tests/test-acl.t tests/test-push-http.t |
diffstat | 3 files changed, 70 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/exchange.py Wed May 27 22:25:33 2015 -0700 +++ b/mercurial/exchange.py Wed May 27 22:25:51 2015 -0700 @@ -524,14 +524,23 @@ return pushop.stepsdone.add('phases') part2node = [] + + def handlefailure(pushop, exc): + targetid = int(exc.partid) + for partid, node in part2node: + if partid == targetid: + raise error.Abort(_('updating %s to public failed') % node) + enc = pushkey.encode for newremotehead in pushop.outdatedphases: - part = bundler.newpart('pushkey', mandatory=False) + part = bundler.newpart('pushkey') part.addparam('namespace', enc('phases')) part.addparam('key', enc(newremotehead.hex())) part.addparam('old', enc(str(phases.draft))) part.addparam('new', enc(str(phases.public))) part2node.append((part.id, newremotehead)) + pushop.pkfailcb[part.id] = handlefailure + def handlereply(op): for partid, node in part2node: partrep = op.records.getreplies(partid)
--- a/tests/test-acl.t Wed May 27 22:25:33 2015 -0700 +++ b/tests/test-acl.t Wed May 27 22:25:51 2015 -0700 @@ -102,7 +102,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -120,7 +120,7 @@ adding quux/file.py revisions added 3 changesets with 3 changes to 3 files bundle2-input-part: total payload size 1606 - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" bundle2-input-bundle: 3 parts total updating the branch cache @@ -166,7 +166,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -186,7 +186,7 @@ calling hook pretxnchangegroup.acl: hgext.acl.hook acl: changes have source "push" - skipping bundle2-input-part: total payload size 1606 - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" bundle2-input-bundle: 3 parts total updating the branch cache @@ -233,7 +233,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -263,7 +263,7 @@ acl: branch access granted: "911600dab2ae" on branch "default" acl: path access granted: "911600dab2ae" bundle2-input-part: total payload size 1606 - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" bundle2-input-bundle: 3 parts total updating the branch cache @@ -310,7 +310,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -375,7 +375,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -445,7 +445,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -512,7 +512,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -584,7 +584,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -653,7 +653,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -724,7 +724,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -754,7 +754,7 @@ acl: branch access granted: "911600dab2ae" on branch "default" acl: path access granted: "911600dab2ae" bundle2-input-part: total payload size 1606 - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" bundle2-input-bundle: 3 parts total updating the branch cache @@ -808,7 +808,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -886,7 +886,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -959,7 +959,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -1043,7 +1043,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -1073,7 +1073,7 @@ acl: branch access granted: "911600dab2ae" on branch "default" acl: path access granted: "911600dab2ae" bundle2-input-part: total payload size 1606 - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" bundle2-input-bundle: 3 parts total updating the branch cache @@ -1130,7 +1130,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -1160,7 +1160,7 @@ acl: branch access granted: "911600dab2ae" on branch "default" acl: path access granted: "911600dab2ae" bundle2-input-part: total payload size 1606 - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" bundle2-input-bundle: 3 parts total updating the branch cache @@ -1213,7 +1213,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -1289,7 +1289,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -1320,7 +1320,7 @@ acl: branch access granted: "911600dab2ae" on branch "default" acl: path access granted: "911600dab2ae" bundle2-input-part: total payload size 1606 - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" bundle2-input-bundle: 3 parts total updating the branch cache @@ -1373,7 +1373,7 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -1488,8 +1488,8 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -1523,9 +1523,9 @@ acl: branch access granted: "e8fc755d4d82" on branch "foobar" acl: path access granted: "e8fc755d4d82" bundle2-input-part: total payload size 2101 - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:e8fc755d4d8217ee5b0c2bb41558c40d43b92c01" bundle2-input-bundle: 4 parts total updating the branch cache @@ -1577,8 +1577,8 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -1651,8 +1651,8 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -1721,8 +1721,8 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -1785,8 +1785,8 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -1820,9 +1820,9 @@ acl: branch access granted: "e8fc755d4d82" on branch "foobar" acl: path access granted: "e8fc755d4d82" bundle2-input-part: total payload size 2101 - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:e8fc755d4d8217ee5b0c2bb41558c40d43b92c01" bundle2-input-bundle: 4 parts total updating the branch cache @@ -1879,8 +1879,8 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -1914,9 +1914,9 @@ acl: branch access granted: "e8fc755d4d82" on branch "foobar" acl: path access granted: "e8fc755d4d82" bundle2-input-part: total payload size 2101 - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:e8fc755d4d8217ee5b0c2bb41558c40d43b92c01" bundle2-input-bundle: 4 parts total updating the branch cache @@ -1972,8 +1972,8 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -2041,8 +2041,8 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155 @@ -2076,9 +2076,9 @@ acl: branch access granted: "e8fc755d4d82" on branch "foobar" acl: path access granted: "e8fc755d4d82" bundle2-input-part: total payload size 2101 - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" - bundle2-input-part: "pushkey" (advisory) (params: 4 mandatory) supported + bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:e8fc755d4d8217ee5b0c2bb41558c40d43b92c01" bundle2-input-bundle: 4 parts total updating the branch cache @@ -2128,8 +2128,8 @@ bundle2-output-part: "replycaps" 155 bytes payload bundle2-output-part: "check:heads" streamed payload bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload - bundle2-output-part: "pushkey" (advisory) (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload + bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload bundle2-input-bundle: with-transaction bundle2-input-part: "replycaps" supported bundle2-input-part: total payload size 155
--- a/tests/test-push-http.t Wed May 27 22:25:33 2015 -0700 +++ b/tests/test-push-http.t Wed May 27 22:25:51 2015 -0700 @@ -125,8 +125,11 @@ remote: added 1 changesets with 1 changes to 1 files remote: prepushkey hook: HG_BUNDLE2=1 HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:* HG_URL=remote:http:127.0.0.1: (glob) remote: pushkey-abort: prepushkey hook exited with status 1 - updating ba677d0156c1 to public failed! + remote: transaction abort! + remote: rollback completed + abort: updating ba677d0156c1 to public failed % serve errors + [255] expect phase change success @@ -134,9 +137,12 @@ $ req pushing to http://localhost:$HGPORT/ searching for changes - no changes found + remote: adding changesets + remote: adding manifests + remote: adding file changes + remote: added 1 changesets with 1 changes to 1 files + remote: prepushkey hook: HG_BUNDLE2=1 HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:* HG_URL=remote:http:127.0.0.1: (glob) % serve errors - [1] $ hg rollback repository tip rolled back to revision 0 (undo serve)