bookmarks: add bookmarks to hidden revs if directaccess config is set
This patch adds support to add bookmarks to hidden revs if
`experimental.directaccessi=True` config is set. A warning is also printed
saying "accessing hidden changeset <revhash>".
Differential Revision: https://phab.mercurial-scm.org/D1813
--- a/mercurial/bookmarks.py Fri Jan 12 11:15:41 2018 +0000
+++ b/mercurial/bookmarks.py Fri Jan 05 22:28:06 2018 +0530
@@ -830,6 +830,7 @@
cur = repo.changectx('.').node()
newact = None
changes = []
+ hiddenrevs = set()
for mark in names:
mark = checkformat(repo, mark)
if newact is None:
@@ -839,10 +840,17 @@
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():
+ hiddenrevs.add(ctx.hex()[:12])
+ tgt = ctx.node()
for bm in marks.checkconflict(mark, force, tgt):
changes.append((bm, None))
changes.append((mark, tgt))
+ if hiddenrevs:
+ repo.ui.warn(_("bookmarking hidden changeset %s\n") %
+ ', '.join(hiddenrevs))
marks.applychanges(repo, tr, changes)
if not inactive and cur == marks[newact] and not rev:
activate(repo, newact)
--- a/tests/test-directaccess.t Fri Jan 12 11:15:41 2018 +0000
+++ b/tests/test-directaccess.t Fri Jan 05 22:28:06 2018 +0530
@@ -186,3 +186,11 @@
abort: hidden revision '2' was rewritten as: 2443a0e66469!
(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
+ bookmarking hidden changeset 28ad74487de9
+
+ $ hg bookmarks
+ book 2:28ad74487de9
--- a/tests/test-log.t Fri Jan 12 11:15:41 2018 +0000
+++ b/tests/test-log.t Fri Jan 05 22:28:06 2018 +0530
@@ -1851,6 +1851,7 @@
bookmarks prevent a changeset being hidden
$ hg bookmark --hidden -r 1 X
+ bookmarking 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
+ bookmarking hidden changeset a765632148dc
$ hg log --template '{rev}:{node}\n'
1:a765632148dc55d38c35c4f247c618701886cb2f
0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
--- a/tests/test-obsolete.t Fri Jan 12 11:15:41 2018 +0000
+++ b/tests/test-obsolete.t Fri Jan 05 22:28:06 2018 +0530
@@ -1333,6 +1333,7 @@
$ echo "hello" > b
$ hg commit --amend -m "message"
$ hg book bookb -r 13bedc178fce --hidden
+ bookmarking hidden changeset 13bedc178fce
$ hg log -r 13bedc178fce
4:13bedc178fce (draft *obsolete*) [ bookb] add b [rewritten using amend as 5:a9b1f8652753]
$ hg book -d bookb
--- a/tests/test-rebase-obsolete.t Fri Jan 12 11:15:41 2018 +0000
+++ b/tests/test-rebase-obsolete.t Fri Jan 05 22:28:06 2018 +0530
@@ -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
+ bookmarking 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)