Mercurial > hg
changeset 25501:a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
When using bundle2, the bookmark's 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:33 -0700 |
parents | 00ecc894138d |
children | bd41c19383db |
files | mercurial/exchange.py tests/test-bookmarks-pushpull.t tests/test-hook.t |
diffstat | 3 files changed, 19 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/exchange.py Mon Jun 08 16:55:21 2015 -0700 +++ b/mercurial/exchange.py Wed May 27 22:25:33 2015 -0700 @@ -569,8 +569,17 @@ pushop.stepsdone.add('bookmarks') part2book = [] enc = pushkey.encode + + def handlefailure(pushop, exc): + targetid = int(exc.partid) + for partid, book, action in part2book: + if partid == targetid: + raise error.Abort(bookmsgmap[action][1].rstrip() % book) + # we should not be called for part we did not generated + assert False + for book, old, new in pushop.outbookmarks: - part = bundler.newpart('pushkey', mandatory=False) + part = bundler.newpart('pushkey') part.addparam('namespace', enc('bookmarks')) part.addparam('key', enc(book)) part.addparam('old', enc(old)) @@ -581,7 +590,7 @@ elif not new: action = 'delete' part2book.append((part.id, book, action)) - + pushop.pkfailcb[part.id] = handlefailure def handlereply(op): ui = pushop.ui
--- a/tests/test-bookmarks-pushpull.t Mon Jun 08 16:55:21 2015 -0700 +++ b/tests/test-bookmarks-pushpull.t Wed May 27 22:25:33 2015 -0700 @@ -755,8 +755,8 @@ searching for changes no changes found pushkey-abort: prepushkey hook exited with status 1 - exporting bookmark @ failed! - [1] + abort: exporting bookmark @ failed! + [255] $ hg -R ../issue4455-dest/ bookmarks no bookmarks set @@ -768,8 +768,8 @@ searching for changes no changes found remote: pushkey-abort: prepushkey hook exited with status 1 - exporting bookmark @ failed! - [1] + abort: exporting bookmark @ failed! + [255] $ hg -R ../issue4455-dest/ bookmarks no bookmarks set @@ -791,8 +791,8 @@ searching for changes no changes found remote: pushkey-abort: prepushkey hook exited with status 1 - exporting bookmark @ failed! - [1] + abort: exporting bookmark @ failed! + [255] $ hg -R ../issue4455-dest/ bookmarks no bookmarks set
--- a/tests/test-hook.t Mon Jun 08 16:55:21 2015 -0700 +++ b/tests/test-hook.t Wed May 27 22:25:33 2015 -0700 @@ -271,11 +271,8 @@ pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=push (glob) prepushkey.forbid hook: HG_BUNDLE2=1 HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_SOURCE=push HG_TXNID=TXN:* HG_URL=push (glob) pushkey-abort: prepushkey hook exited with status 1 - pretxnclose hook: HG_BUNDLE2=1 HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=push (glob) - txnclose hook: HG_BUNDLE2=1 HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=push (glob) - exporting bookmark baz failed! - listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'} - [1] + abort: exporting bookmark baz failed! + [255] $ cd ../a test that prelistkeys can prevent listing keys