mercurial/exchange.py
branchstable
changeset 42670 3332bde53714
parent 42348 5d4ec64a6fcb
child 42830 10841b9a80c3
--- a/mercurial/exchange.py	Sun Aug 18 02:47:32 2019 +0530
+++ b/mercurial/exchange.py	Sat Aug 17 01:49:28 2019 +0530
@@ -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))