diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -1034,6 +1034,15 @@ return 'delete' return 'update' +def _abortonsecretctx(pushop, node, b): + """abort if a given bookmark points to a secret changeset""" + if not node: + return False + ctx = pushop.repo[node] + if ctx.phase() == phases.secret: + raise error.Abort(_('bookmark %s points to a secret changeset') % b) + return False + def _pushb2bookmarkspart(pushop, bundler): pushop.stepsdone.add('bookmarks') if not pushop.outbookmarks: @@ -1042,6 +1051,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 +1080,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)) diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t --- a/tests/test-bookmarks-pushpull.t +++ b/tests/test-bookmarks-pushpull.t @@ -1322,3 +1322,42 @@ abort: push failed on remote [255] #endif + +-- test for stop pushing bookmarks pointing to secret changesets + +Set up a "remote" repo + $ hg init issue6159remote + $ cd issue6159remote + $ echo a > a + $ hg add a + $ hg commit -m_ + $ hg bookmark foo + $ cd .. + +Clone a local repo + $ hg clone -q issue6159remote issue6159local + $ cd issue6159local + $ hg up -qr foo + $ echo b > b + +Move the bookmark "foo" to point at a secret changeset + $ hg commit -qAm_ + $ hg phase -s -f + +Pushing the bookmark "foo" now fails as it contains a secret changeset +#if b2-pushkey + $ hg push -r foo + pushing to $TESTTMP/issue6159remote + searching for changes + no changes found (ignored 1 secret changesets) + abort: bookmark foo points to a secret changeset + [255] +#endif +#if b2-binary + $ hg push -r foo + pushing to $TESTTMP/issue6159remote + searching for changes + no changes found (ignored 1 secret changesets) + abort: bookmark foo points to a secret changeset + [255] +#endif