From patchwork Fri Aug 23 19:05:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D6731: exchange: abort on pushing bookmarks pointing to secret changesets (issue6159) From: phabricator X-Patchwork-Id: 41390 Message-Id: <71394ce52cecd5f0d3c18a711f8e3ade@localhost.localdomain> To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Fri, 23 Aug 2019 19:05:43 +0000 navaneeth.suresh updated this revision to Diff 16299. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6731?vs=16291&id=16299 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6731/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6731 AFFECTED FILES mercurial/exchange.py CHANGE DETAILS To: navaneeth.suresh, #hg-reviewers Cc: pulkit, mercurial-devel diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -1034,6 +1034,12 @@ return 'delete' return 'update' +def _abortonsecretctx(pushop, node, b): + """abort if a given bookmark points to a secret changeset""" + if node and pushop.repo[node].phase() == phases.secret: + raise error.Abort(_('cannot push bookmark %s as it points to a secret' + ' changeset') % b) + def _pushb2bookmarkspart(pushop, bundler): pushop.stepsdone.add('bookmarks') if not pushop.outbookmarks: @@ -1042,6 +1048,7 @@ allactions = [] data = [] for book, old, new in pushop.outbookmarks: + _abortonsecretctx(pushop, new, book) new = bin(new) data.append((book, new)) allactions.append((book, _bmaction(old, new))) @@ -1070,6 +1077,7 @@ assert False for book, old, new in pushop.outbookmarks: + _abortonsecretctx(pushop, new, book) part = bundler.newpart('pushkey') part.addparam('namespace', enc('bookmarks')) part.addparam('key', enc(book))