D6731: exchange: abort on pushing bookmarks pointing to secret changesets (issue6159)

navaneeth.suresh (Navaneeth Suresh) phabricator at mercurial-scm.org
Sat Aug 17 17:29:13 EDT 2019


navaneeth.suresh updated this revision to Diff 16258.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6731?vs=16225&id=16258

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6731/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6731

AFFECTED FILES
  mercurial/exchange.py
  tests/test-bookmarks-pushpull.t

CHANGE DETAILS

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
@@ -1343,9 +1343,6 @@
 Move the bookmark "foo" to point at a secret changeset
   $ hg commit -qAm_
   $ hg phase -s -f
-  $ hg log -r . --template '{node}'
-  cf489fd8a374cab73c2dc19e899bde6fe3a43f8f (no-eol)
-
 
 Pushing the bookmark "foo" now fails as it contains a secret changeset
 #if b2-pushkey
@@ -1353,60 +1350,14 @@
   pushing to $TESTTMP/issue6159remote
   searching for changes
   no changes found (ignored 1 secret changesets)
-  abort: updating bookmark foo failed!
+  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)
-  updating bookmark foo
-  [1]
+  abort: bookmark foo points to a secret changeset
+  [255]
 #endif
-
-Now the "remote" repo contains a bookmark pointing to a nonexistent revision
-#if b2-pushkey
-  $ cd ../a
-  $ hg bookmark
-     @                         1:0d2164f0ce0d
-     @1                        2:9b140be10808
-   * X                         1:0d2164f0ce0d
-     X at 1                       2:9b140be10808
-     Y                         5:c922c0139ca0
-     Z                         1:0d2164f0ce0d
-     foo                       -1:000000000000
-     foobar                    2:9b140be10808
-  $ cat .hg/bookmarks
-  0d2164f0ce0d8f1d6f94351eba04b794909be66c @
-  9b140be1080824d768c5a4691a564088eede71f9 @1
-  0d2164f0ce0d8f1d6f94351eba04b794909be66c X
-  9b140be1080824d768c5a4691a564088eede71f9 X at 1
-  c922c0139ca03858f655e4a2af4dd02796a63969 Y
-  0d2164f0ce0d8f1d6f94351eba04b794909be66c Z
-  0000000000000000000000000000000000000000 foo
-  9b140be1080824d768c5a4691a564088eede71f9 foobar
-#endif
-
-#if b2-binary
-  $ cd ../a
-  $ hg bookmark
-     @                         1:0d2164f0ce0d
-     @1                        2:9b140be10808
-   * X                         1:0d2164f0ce0d
-     X at 1                       2:9b140be10808
-     Y                         5:c922c0139ca0
-     Z                         1:0d2164f0ce0d
-     foo                       -1:000000000000
-     foobar                    2:9b140be10808
-  $ cat .hg/bookmarks
-  0d2164f0ce0d8f1d6f94351eba04b794909be66c @
-  9b140be1080824d768c5a4691a564088eede71f9 @1
-  0d2164f0ce0d8f1d6f94351eba04b794909be66c X
-  9b140be1080824d768c5a4691a564088eede71f9 X at 1
-  c922c0139ca03858f655e4a2af4dd02796a63969 Y
-  0d2164f0ce0d8f1d6f94351eba04b794909be66c Z
-  0000000000000000000000000000000000000000 foo
-  9b140be1080824d768c5a4691a564088eede71f9 foobar
-#endif
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))



To: navaneeth.suresh, #hg-reviewers
Cc: pulkit, mercurial-devel


More information about the Mercurial-devel mailing list