diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -853,7 +853,11 @@ return tgt = cur if rev: - tgt = scmutil.revsingle(repo, rev).node() + repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn') + ctx = scmutil.revsingle(repo, rev) + if ctx.hidden(): + repo.ui.warn(_("accessing hidden changeset %s\n") % ctx) + tgt = ctx.node() for bm in marks.checkconflict(mark, force, tgt): changes.append((bm, None)) changes.append((mark, tgt)) diff --git a/tests/test-directaccess.t b/tests/test-directaccess.t --- a/tests/test-directaccess.t +++ b/tests/test-directaccess.t @@ -186,3 +186,11 @@ abort: hidden revision '2'! (use --hidden to access hidden revisions) [255] + +Setting a bookmark will make that changeset unhidden, so this should come in end + + $ hg bookmarks -r 28ad74 book + accessing hidden changeset 28ad74487de9 + + $ hg bookmarks + book 2:28ad74487de9 diff --git a/tests/test-log.t b/tests/test-log.t --- a/tests/test-log.t +++ b/tests/test-log.t @@ -1851,6 +1851,7 @@ bookmarks prevent a changeset being hidden $ hg bookmark --hidden -r 1 X + accessing hidden changeset a765632148dc $ hg log --template '{rev}:{node}\n' 1:a765632148dc55d38c35c4f247c618701886cb2f 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05 @@ -1859,6 +1860,7 @@ divergent bookmarks are not hidden $ hg bookmark --hidden -r 1 X@foo + accessing hidden changeset a765632148dc $ hg log --template '{rev}:{node}\n' 1:a765632148dc55d38c35c4f247c618701886cb2f 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05 diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t --- a/tests/test-obsolete.t +++ b/tests/test-obsolete.t @@ -1333,6 +1333,7 @@ $ echo "hello" > b $ hg commit --amend -m "message" $ hg book bookb -r 13bedc178fce --hidden + accessing hidden changeset 13bedc178fce $ hg log -r 13bedc178fce 4:13bedc178fce (draft *obsolete*) [ bookb] add b [rewritten using amend as 5:a9b1f8652753] $ hg book -d bookb diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t --- a/tests/test-rebase-obsolete.t +++ b/tests/test-rebase-obsolete.t @@ -1496,6 +1496,7 @@ $ hg log -r . # working dir is at rev 3 (successor of 2) 3:be1832deae9a b (no-eol) $ hg book -r 2 mybook --hidden # rev 2 has a bookmark on it now + accessing hidden changeset 1e9a3c00cbe9 $ hg up 2 && hg log -r . # working dir is at rev 2 again 0 files updated, 0 files merged, 1 files removed, 0 files unresolved 2:1e9a3c00cbe9 b (rewritten using rebase as 3:be1832deae9a) (no-eol)