Debian Codegraph @

tests/test-share-bookmarks.t

raw
1 #testcases vfs svfs
2 #testcases safe normal
3
4 #if safe
5 $ echo "[format]" >> $HGRCPATH
6 $ echo "use-share-safe = True" >> $HGRCPATH
7 #endif
8
9 $ echo "[extensions]" >> $HGRCPATH
10 $ echo "share = " >> $HGRCPATH
11
12 #if svfs
13 $ echo "[format]" >> $HGRCPATH
14 $ echo "bookmarks-in-store = yes " >> $HGRCPATH
15 #endif
16
17 prepare repo1
18
19 $ hg init repo1
20 $ cd repo1
21 $ echo a > a
22 $ hg commit -A -m'init'
23 adding a
24 $ echo a >> a
25 $ hg commit -m'change in shared clone'
26 $ echo b > b
27 $ hg commit -A -m'another file'
28 adding b
29
30 share it
31
32 $ cd ..
33 $ hg share repo1 repo2
34 updating working directory
35 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
36
37 test sharing bookmarks
38
39 $ hg share -B repo1 repo3
40 updating working directory
41 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
42 $ cd repo1
43 $ hg bookmark bm1
44 $ hg bookmarks
45 * bm1 2:c2e0ac586386
46 $ cd ../repo2
47 $ hg book bm2
48 $ hg bookmarks
49 bm1 2:c2e0ac586386 (svfs !)
50 * bm2 2:c2e0ac586386
51 $ cd ../repo3
52 $ hg bookmarks
53 bm1 2:c2e0ac586386
54 bm2 2:c2e0ac586386 (svfs !)
55 $ hg book bm3
56 $ hg bookmarks
57 bm1 2:c2e0ac586386
58 bm2 2:c2e0ac586386 (svfs !)
59 * bm3 2:c2e0ac586386
60 $ cd ../repo1
61 $ hg bookmarks
62 * bm1 2:c2e0ac586386
63 bm2 2:c2e0ac586386 (svfs !)
64 bm3 2:c2e0ac586386
65
66 check whether HG_PENDING makes pending changes only in relatd
67 repositories visible to an external hook.
68
69 In "hg share" case, another transaction can't run in other
70 repositories sharing same source repository, because starting
71 transaction requires locking store of source repository.
72
73 Therefore, this test scenario ignores checking visibility of
74 .hg/bookmarks.pending in repo2, which shares repo1 without bookmarks.
75
76 $ cat > $TESTTMP/checkbookmarks.sh <<EOF
77 > echo "@repo1"
78 > hg -R "$TESTTMP/repo1" bookmarks
79 > echo "@repo2"
80 > hg -R "$TESTTMP/repo2" bookmarks
81 > echo "@repo3"
82 > hg -R "$TESTTMP/repo3" bookmarks
83 > exit 1 # to avoid adding new bookmark for subsequent tests
84 > EOF
85
86 $ cd ../repo1
87 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkbookmarks.sh" -q book bmX
88 @repo1
89 bm1 2:c2e0ac586386
90 bm2 2:c2e0ac586386 (svfs !)
91 bm3 2:c2e0ac586386
92 * bmX 2:c2e0ac586386
93 @repo2
94 bm1 2:c2e0ac586386 (svfs !)
95 * bm2 2:c2e0ac586386
96 bm3 2:c2e0ac586386 (svfs !)
97 @repo3
98 bm1 2:c2e0ac586386
99 bm2 2:c2e0ac586386 (svfs !)
100 * bm3 2:c2e0ac586386
101 bmX 2:c2e0ac586386 (vfs !)
102 abort: pretxnclose hook exited with status 1
103 [40]
104 $ hg book bm1
105
106 FYI, in contrast to above test, bmX is invisible in repo1 (= shared
107 src), because (1) HG_PENDING refers only repo3 and (2)
108 "bookmarks.pending" is written only into repo3.
109
110 $ cd ../repo3
111 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkbookmarks.sh" -q book bmX
112 @repo1
113 * bm1 2:c2e0ac586386
114 bm2 2:c2e0ac586386 (svfs !)
115 bm3 2:c2e0ac586386
116 @repo2
117 bm1 2:c2e0ac586386 (svfs !)
118 * bm2 2:c2e0ac586386
119 bm3 2:c2e0ac586386 (svfs !)
120 @repo3
121 bm1 2:c2e0ac586386
122 bm2 2:c2e0ac586386 (svfs !)
123 bm3 2:c2e0ac586386
124 * bmX 2:c2e0ac586386
125 abort: pretxnclose hook exited with status 1
126 [40]
127 $ hg book bm3
128
129 clean up bm2 since it's uninteresting (not shared in the vfs case and
130 same as bm3 in the svfs case)
131 $ cd ../repo2
132 $ hg book -d bm2
133
134 $ cd ../repo1
135
136 test that commits work
137
138 $ echo 'shared bookmarks' > a
139 $ hg commit -m 'testing shared bookmarks'
140 $ hg bookmarks
141 * bm1 3:b87954705719
142 bm3 2:c2e0ac586386
143 $ cd ../repo3
144 $ hg bookmarks
145 bm1 3:b87954705719
146 * bm3 2:c2e0ac586386
147 $ echo 'more shared bookmarks' > a
148 $ hg commit -m 'testing shared bookmarks'
149 created new head
150 $ hg bookmarks
151 bm1 3:b87954705719
152 * bm3 4:62f4ded848e4
153 $ cd ../repo1
154 $ hg bookmarks
155 * bm1 3:b87954705719
156 bm3 4:62f4ded848e4
157 $ cd ..
158
159 test pushing bookmarks works
160
161 $ hg clone repo3 repo4
162 updating to branch default
163 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
164 $ cd repo4
165 $ hg boo bm4
166 $ echo foo > b
167 $ hg commit -m 'foo in b'
168 $ hg boo
169 bm1 3:b87954705719
170 bm3 4:62f4ded848e4
171 * bm4 5:92793bfc8cad
172 $ hg push -B bm4
173 pushing to $TESTTMP/repo3
174 searching for changes
175 adding changesets
176 adding manifests
177 adding file changes
178 added 1 changesets with 1 changes to 1 files
179 exporting bookmark bm4
180 $ cd ../repo1
181 $ hg bookmarks
182 * bm1 3:b87954705719
183 bm3 4:62f4ded848e4
184 bm4 5:92793bfc8cad
185 $ cd ../repo3
186 $ hg bookmarks
187 bm1 3:b87954705719
188 * bm3 4:62f4ded848e4
189 bm4 5:92793bfc8cad
190 $ cd ..
191
192 test behavior when sharing a shared repo
193
194 $ hg share -B repo3 missingdir/repo5
195 updating working directory
196 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
197 $ cd missingdir/repo5
198 $ hg book
199 bm1 3:b87954705719
200 bm3 4:62f4ded848e4
201 bm4 5:92793bfc8cad
202 $ cd ../..
203
204 test what happens when an active bookmark is deleted
205
206 $ cd repo1
207 $ hg boo -d bm3
208 $ hg boo
209 * bm1 3:b87954705719
210 bm4 5:92793bfc8cad
211 $ cd ../repo3
212 $ hg boo
213 bm1 3:b87954705719
214 bm4 5:92793bfc8cad
215 $ cd ..
216
217 verify that bookmarks are not written on failed transaction
218
219 $ cat > failpullbookmarks.py << EOF
220 > """A small extension that makes bookmark pulls fail, for testing"""
221 > from mercurial import (
222 > error,
223 > exchange,
224 > extensions,
225 > )
226 > def _pullbookmarks(orig, pullop):
227 > orig(pullop)
228 > raise error.HookAbort(b'forced failure by extension')
229 > def extsetup(ui):
230 > extensions.wrapfunction(exchange, '_pullbookmarks', _pullbookmarks)
231 > EOF
232 $ cd repo4
233 $ hg boo
234 bm1 3:b87954705719
235 bm3 4:62f4ded848e4
236 * bm4 5:92793bfc8cad
237 $ cd ../repo3
238 $ hg boo
239 bm1 3:b87954705719
240 bm4 5:92793bfc8cad
241 $ hg --config "extensions.failpullbookmarks=$TESTTMP/failpullbookmarks.py" pull $TESTTMP/repo4
242 pulling from $TESTTMP/repo4
243 searching for changes
244 no changes found
245 adding remote bookmark bm3
246 abort: forced failure by extension
247 [40]
248 $ hg boo
249 bm1 3:b87954705719
250 bm4 5:92793bfc8cad
251 $ hg pull $TESTTMP/repo4
252 pulling from $TESTTMP/repo4
253 searching for changes
254 no changes found
255 adding remote bookmark bm3
256 1 local changesets published
257 $ hg boo
258 bm1 3:b87954705719
259 * bm3 4:62f4ded848e4
260 bm4 5:92793bfc8cad
261 $ cd ..
262
263 verify bookmark behavior after unshare
264
265 $ cd repo3
266 $ hg unshare
267 $ hg boo
268 bm1 3:b87954705719
269 * bm3 4:62f4ded848e4
270 bm4 5:92793bfc8cad
271 $ hg boo -d bm4
272 $ hg boo bm5
273 $ hg boo
274 bm1 3:b87954705719
275 bm3 4:62f4ded848e4
276 * bm5 4:62f4ded848e4
277 $ cd ../repo1
278 $ hg boo
279 * bm1 3:b87954705719
280 bm3 4:62f4ded848e4
281 bm4 5:92793bfc8cad
282 $ cd ..
283
284 Test that if store is disabled, we drop the bookmarksinstore requirement
285
286 $ hg init brokenrepo --config format.bookmarks-in-store=True --config format.usestore=false
287 ignoring enabled 'format.bookmarks-in-store' config beacuse it is incompatible with disabled 'format.usestore' config
288 ignoring enabled 'format.use-share-safe' config because it is incompatible with disabled 'format.usestore' config (safe !)