##// END OF EJS Templates
repoview: introduce a filter for serving hidden changesets...
marmoute -
r42295:ef0e3cc6 default
parent child Browse files
Show More
@@ -0,0 +1,97 b''
1 ========================================================
2 Test the ability to access a hidden revision on a server
3 ========================================================
4
5 #require serve
6
7 $ . $TESTDIR/testlib/obsmarker-common.sh
8 $ cat >> $HGRCPATH << EOF
9 > [phases]
10 > # public changeset are not obsolete
11 > publish=false
12 > [experimental]
13 > evolution=all
14 > [ui]
15 > logtemplate='{rev}:{node|short} {desc} [{phase}]\n'
16 > EOF
17
18 Setup a simple repository with some hidden revisions
19 ----------------------------------------------------
20
21 Testing the `served.hidden` view
22
23 $ hg init repo-with-hidden
24 $ cd repo-with-hidden
25
26 $ echo 0 > a
27 $ hg ci -qAm "c_Public"
28 $ hg phase --public
29 $ echo 1 > a
30 $ hg ci -m "c_Amend_Old"
31 $ echo 2 > a
32 $ hg ci -m "c_Amend_New" --amend
33 $ hg up ".^"
34 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
35 $ echo 3 > a
36 $ hg ci -m "c_Pruned"
37 created new head
38 $ hg debugobsolete --record-parents `getid 'desc("c_Pruned")'` -d '0 0'
39 obsoleted 1 changesets
40 $ hg up ".^"
41 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
42 $ echo 4 > a
43 $ hg ci -m "c_Secret" --secret
44 created new head
45 $ echo 5 > a
46 $ hg ci -m "c_Secret_Pruned" --secret
47 $ hg debugobsolete --record-parents `getid 'desc("c_Secret_Pruned")'` -d '0 0'
48 obsoleted 1 changesets
49 $ hg up null
50 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
51
52 $ hg log -G -T '{rev}:{node|short} {desc} [{phase}]\n' --hidden
53 x 5:8d28cbe335f3 c_Secret_Pruned [secret]
54 |
55 o 4:1c6afd79eb66 c_Secret [secret]
56 |
57 | x 3:5d1575e42c25 c_Pruned [draft]
58 |/
59 | o 2:c33affeb3f6b c_Amend_New [draft]
60 |/
61 | x 1:be215fbb8c50 c_Amend_Old [draft]
62 |/
63 o 0:5f354f46e585 c_Public [public]
64
65 $ hg debugobsolete
66 be215fbb8c5090028b00154c1fe877ad1b376c61 c33affeb3f6b4e9621d1839d6175ddc07708807c 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'amend', 'user': 'test'}
67 5d1575e42c25b7f2db75cd4e0b881b1c35158fae 0 {5f354f46e5853535841ec7a128423e991ca4d59b} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
68 8d28cbe335f311bc89332d7bbe8a07889b6914a0 0 {1c6afd79eb6663275bbe30097e162b1c24ced0f0} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
69
70 $ cd ..
71
72 Test the feature
73 ================
74
75 Check that the `served.hidden` repoview
76 ---------------------------------------
77
78 $ hg -R repo-with-hidden serve -p $HGPORT -d --pid-file hg.pid --config web.view=served.hidden
79 $ cat hg.pid >> $DAEMON_PIDS
80
81 changesets in secret and higher phases are not visible through hgweb
82
83 $ hg -R repo-with-hidden log --template "revision: {rev}\\n" --rev "reverse(not secret())"
84 revision: 2
85 revision: 0
86 $ hg -R repo-with-hidden log --template "revision: {rev}\\n" --rev "reverse(not secret())" --hidden
87 revision: 3
88 revision: 2
89 revision: 1
90 revision: 0
91 $ get-with-headers.py localhost:$HGPORT 'log?style=raw' | grep revision:
92 revision: 3
93 revision: 2
94 revision: 1
95 revision: 0
96
97 $ killdaemons.py
@@ -40,6 +40,7 b' unpack_from = struct.unpack_from'
40 subsettable = {None: 'visible',
40 subsettable = {None: 'visible',
41 'visible-hidden': 'visible',
41 'visible-hidden': 'visible',
42 'visible': 'served',
42 'visible': 'served',
43 'served.hidden': 'served',
43 'served': 'immutable',
44 'served': 'immutable',
44 'immutable': 'base'}
45 'immutable': 'base'}
45
46
@@ -86,6 +86,14 b' def computehidden(repo, visibilityexcept'
86 _revealancestors(pfunc, hidden, visible)
86 _revealancestors(pfunc, hidden, visible)
87 return frozenset(hidden)
87 return frozenset(hidden)
88
88
89 def computesecret(repo, visibilityexceptions=None):
90 """compute the set of revision that can never be exposed through hgweb
91
92 Changeset in the secret phase (or above) should stay unaccessible."""
93 assert not repo.changelog.filteredrevs
94 secrets = repo._phasecache.getrevset(repo, phases.remotehiddenphases)
95 return frozenset(secrets)
96
89 def computeunserved(repo, visibilityexceptions=None):
97 def computeunserved(repo, visibilityexceptions=None):
90 """compute the set of revision that should be filtered when used a server
98 """compute the set of revision that should be filtered when used a server
91
99
@@ -93,9 +101,9 b' def computeunserved(repo, visibilityexce'
93 assert not repo.changelog.filteredrevs
101 assert not repo.changelog.filteredrevs
94 # fast path in simple case to avoid impact of non optimised code
102 # fast path in simple case to avoid impact of non optimised code
95 hiddens = filterrevs(repo, 'visible')
103 hiddens = filterrevs(repo, 'visible')
96 secrets = repo._phasecache.getrevset(repo, phases.remotehiddenphases)
104 secrets = filterrevs(repo, 'served.hidden')
97 if secrets:
105 if secrets:
98 return frozenset(hiddens | frozenset(secrets))
106 return frozenset(hiddens | secrets)
99 else:
107 else:
100 return hiddens
108 return hiddens
101
109
@@ -141,6 +149,7 b' def computeimpactable(repo, visibilityex'
141 # from scratch (very slow).
149 # from scratch (very slow).
142 filtertable = {'visible': computehidden,
150 filtertable = {'visible': computehidden,
143 'visible-hidden': computehidden,
151 'visible-hidden': computehidden,
152 'served.hidden': computesecret,
144 'served': computeunserved,
153 'served': computeunserved,
145 'immutable': computemutable,
154 'immutable': computemutable,
146 'base': computeimpactable}
155 'base': computeimpactable}
General Comments 0
You need to be logged in to leave comments. Login now