]>
Commit | Line | Data |
---|---|---|
c700b684 PW |
1 | #!/bin/sh |
2 | ||
6ab1d76c | 3 | test_description='git p4 client view' |
c700b684 PW |
4 | |
5 | . ./lib-git-p4.sh | |
6 | ||
7 | test_expect_success 'start p4d' ' | |
8 | start_p4d | |
9 | ' | |
10 | ||
11 | # | |
12 | # Construct a client with this list of View lines | |
13 | # | |
14 | client_view() { | |
15 | ( | |
16 | cat <<-EOF && | |
17 | Client: client | |
18 | Description: client | |
19 | Root: $cli | |
20 | View: | |
21 | EOF | |
22 | for arg ; do | |
23 | printf "\t$arg\n" | |
24 | done | |
25 | ) | p4 client -i | |
26 | } | |
27 | ||
28 | # | |
29 | # Verify these files exist, exactly. Caller creates | |
30 | # a list of files in file "files". | |
31 | # | |
32 | check_files_exist() { | |
33 | ok=0 && | |
8d93a5ac | 34 | num=$# && |
c700b684 PW |
35 | for arg ; do |
36 | test_path_is_file "$arg" && | |
37 | ok=$(($ok + 1)) | |
38 | done && | |
39 | test $ok -eq $num && | |
40 | test_line_count = $num files | |
41 | } | |
42 | ||
43 | # | |
44 | # Sync up the p4 client, make sure the given files (and only | |
45 | # those) exist. | |
46 | # | |
47 | client_verify() { | |
48 | ( | |
49 | cd "$cli" && | |
50 | p4 sync && | |
51 | find . -type f ! -name files >files && | |
52 | check_files_exist "$@" | |
53 | ) | |
54 | } | |
55 | ||
56 | # | |
57 | # Make sure the named files, exactly, exist. | |
58 | # | |
59 | git_verify() { | |
60 | ( | |
61 | cd "$git" && | |
62 | git ls-files >files && | |
63 | check_files_exist "$@" | |
64 | ) | |
65 | } | |
66 | ||
67 | # //depot | |
68 | # - dir1 | |
69 | # - file11 | |
70 | # - file12 | |
71 | # - dir2 | |
72 | # - file21 | |
73 | # - file22 | |
543987bd PW |
74 | init_depot() { |
75 | for d in 1 2 ; do | |
76 | mkdir -p dir$d && | |
77 | for f in 1 2 ; do | |
78 | echo dir$d/file$d$f >dir$d/file$d$f && | |
79 | p4 add dir$d/file$d$f && | |
80 | p4 submit -d "dir$d/file$d$f" | |
81 | done | |
82 | done && | |
83 | find . -type f ! -name files >files && | |
84 | check_files_exist dir1/file11 dir1/file12 \ | |
85 | dir2/file21 dir2/file22 | |
86 | } | |
87 | ||
c700b684 PW |
88 | test_expect_success 'init depot' ' |
89 | ( | |
90 | cd "$cli" && | |
543987bd | 91 | init_depot |
c700b684 PW |
92 | ) |
93 | ' | |
94 | ||
95 | # double % for printf | |
b10048d0 | 96 | test_expect_success 'unsupported view wildcard %%n' ' |
c700b684 PW |
97 | client_view "//depot/%%%%1/sub/... //client/sub/%%%%1/..." && |
98 | test_when_finished cleanup_git && | |
6ab1d76c | 99 | test_must_fail git p4 clone --use-client-spec --dest="$git" //depot |
c700b684 PW |
100 | ' |
101 | ||
b10048d0 | 102 | test_expect_success 'unsupported view wildcard *' ' |
c700b684 PW |
103 | client_view "//depot/*/bar/... //client/*/bar/..." && |
104 | test_when_finished cleanup_git && | |
6ab1d76c | 105 | test_must_fail git p4 clone --use-client-spec --dest="$git" //depot |
c700b684 PW |
106 | ' |
107 | ||
43b82bd9 | 108 | test_expect_success 'wildcard ... only supported at end of spec 1' ' |
c700b684 PW |
109 | client_view "//depot/.../file11 //client/.../file11" && |
110 | test_when_finished cleanup_git && | |
6ab1d76c | 111 | test_must_fail git p4 clone --use-client-spec --dest="$git" //depot |
c700b684 PW |
112 | ' |
113 | ||
43b82bd9 PW |
114 | test_expect_success 'wildcard ... only supported at end of spec 2' ' |
115 | client_view "//depot/.../a/... //client/.../a/..." && | |
116 | test_when_finished cleanup_git && | |
6ab1d76c | 117 | test_must_fail git p4 clone --use-client-spec --dest="$git" //depot |
43b82bd9 PW |
118 | ' |
119 | ||
ecb7cf98 | 120 | test_expect_success 'basic map' ' |
c700b684 PW |
121 | client_view "//depot/dir1/... //client/cli1/..." && |
122 | files="cli1/file11 cli1/file12" && | |
123 | client_verify $files && | |
124 | test_when_finished cleanup_git && | |
6ab1d76c | 125 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
126 | git_verify $files |
127 | ' | |
128 | ||
ecb7cf98 | 129 | test_expect_success 'client view with no mappings' ' |
c700b684 PW |
130 | client_view && |
131 | client_verify && | |
132 | test_when_finished cleanup_git && | |
6ab1d76c | 133 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
134 | git_verify |
135 | ' | |
136 | ||
ecb7cf98 | 137 | test_expect_success 'single file map' ' |
c700b684 PW |
138 | client_view "//depot/dir1/file11 //client/file11" && |
139 | files="file11" && | |
140 | client_verify $files && | |
141 | test_when_finished cleanup_git && | |
6ab1d76c | 142 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
143 | git_verify $files |
144 | ' | |
145 | ||
df5ed907 | 146 | test_expect_success 'later mapping takes precedence (entire repo)' ' |
c700b684 PW |
147 | client_view "//depot/dir1/... //client/cli1/..." \ |
148 | "//depot/... //client/cli2/..." && | |
149 | files="cli2/dir1/file11 cli2/dir1/file12 | |
150 | cli2/dir2/file21 cli2/dir2/file22" && | |
151 | client_verify $files && | |
152 | test_when_finished cleanup_git && | |
6ab1d76c | 153 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
154 | git_verify $files |
155 | ' | |
156 | ||
ecb7cf98 | 157 | test_expect_success 'later mapping takes precedence (partial repo)' ' |
c700b684 PW |
158 | client_view "//depot/dir1/... //client/..." \ |
159 | "//depot/dir2/... //client/..." && | |
160 | files="file21 file22" && | |
161 | client_verify $files && | |
162 | test_when_finished cleanup_git && | |
6ab1d76c | 163 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
164 | git_verify $files |
165 | ' | |
166 | ||
167 | # Reading the view backwards, | |
168 | # dir2 goes to cli12 | |
169 | # dir1 cannot go to cli12 since it was filled by dir2 | |
170 | # dir1 also does not go to cli3, since the second rule | |
171 | # noticed that it matched, but was already filled | |
ecb7cf98 | 172 | test_expect_success 'depot path matching rejected client path' ' |
c700b684 PW |
173 | client_view "//depot/dir1/... //client/cli3/..." \ |
174 | "//depot/dir1/... //client/cli12/..." \ | |
175 | "//depot/dir2/... //client/cli12/..." && | |
176 | files="cli12/file21 cli12/file22" && | |
177 | client_verify $files && | |
178 | test_when_finished cleanup_git && | |
6ab1d76c | 179 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
180 | git_verify $files |
181 | ' | |
182 | ||
183 | # since both have the same //client/..., the exclusion | |
184 | # rule keeps everything out | |
ecb7cf98 | 185 | test_expect_success 'exclusion wildcard, client rhs same (odd)' ' |
c700b684 PW |
186 | client_view "//depot/... //client/..." \ |
187 | "-//depot/dir2/... //client/..." && | |
188 | client_verify && | |
189 | test_when_finished cleanup_git && | |
6ab1d76c | 190 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
191 | git_verify |
192 | ' | |
193 | ||
194 | test_expect_success 'exclusion wildcard, client rhs different (normal)' ' | |
195 | client_view "//depot/... //client/..." \ | |
196 | "-//depot/dir2/... //client/dir2/..." && | |
197 | files="dir1/file11 dir1/file12" && | |
198 | client_verify $files && | |
199 | test_when_finished cleanup_git && | |
6ab1d76c | 200 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
201 | git_verify $files |
202 | ' | |
203 | ||
e3e68643 | 204 | test_expect_success 'exclusion single file' ' |
c700b684 PW |
205 | client_view "//depot/... //client/..." \ |
206 | "-//depot/dir2/file22 //client/file22" && | |
207 | files="dir1/file11 dir1/file12 dir2/file21" && | |
208 | client_verify $files && | |
209 | test_when_finished cleanup_git && | |
6ab1d76c | 210 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
211 | git_verify $files |
212 | ' | |
213 | ||
ecb7cf98 | 214 | test_expect_success 'overlay wildcard' ' |
c700b684 PW |
215 | client_view "//depot/dir1/... //client/cli/..." \ |
216 | "+//depot/dir2/... //client/cli/...\n" && | |
217 | files="cli/file11 cli/file12 cli/file21 cli/file22" && | |
218 | client_verify $files && | |
219 | test_when_finished cleanup_git && | |
6ab1d76c | 220 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
221 | git_verify $files |
222 | ' | |
223 | ||
ecb7cf98 | 224 | test_expect_success 'overlay single file' ' |
c700b684 PW |
225 | client_view "//depot/dir1/... //client/cli/..." \ |
226 | "+//depot/dir2/file21 //client/cli/file21" && | |
227 | files="cli/file11 cli/file12 cli/file21" && | |
228 | client_verify $files && | |
229 | test_when_finished cleanup_git && | |
6ab1d76c | 230 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
231 | git_verify $files |
232 | ' | |
233 | ||
ecb7cf98 | 234 | test_expect_success 'exclusion with later inclusion' ' |
c700b684 PW |
235 | client_view "//depot/... //client/..." \ |
236 | "-//depot/dir2/... //client/dir2/..." \ | |
237 | "//depot/dir2/... //client/dir2incl/..." && | |
238 | files="dir1/file11 dir1/file12 dir2incl/file21 dir2incl/file22" && | |
239 | client_verify $files && | |
240 | test_when_finished cleanup_git && | |
6ab1d76c | 241 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
242 | git_verify $files |
243 | ' | |
244 | ||
ecb7cf98 | 245 | test_expect_success 'quotes on rhs only' ' |
c700b684 PW |
246 | client_view "//depot/dir1/... \"//client/cdir 1/...\"" && |
247 | client_verify "cdir 1/file11" "cdir 1/file12" && | |
248 | test_when_finished cleanup_git && | |
6ab1d76c | 249 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
250 | git_verify "cdir 1/file11" "cdir 1/file12" |
251 | ' | |
252 | ||
a93d33ee PW |
253 | # |
254 | # Submit tests | |
255 | # | |
256 | ||
257 | # clone sets variable | |
258 | test_expect_success 'clone --use-client-spec sets useClientSpec' ' | |
259 | client_view "//depot/... //client/..." && | |
260 | test_when_finished cleanup_git && | |
6ab1d76c | 261 | git p4 clone --use-client-spec --dest="$git" //depot && |
a93d33ee PW |
262 | ( |
263 | cd "$git" && | |
264 | git config --bool git-p4.useClientSpec >actual && | |
265 | echo true >true && | |
266 | test_cmp actual true | |
267 | ) | |
268 | ' | |
269 | ||
543987bd PW |
270 | # clone just a subdir of the client spec |
271 | test_expect_success 'subdir clone' ' | |
272 | client_view "//depot/... //client/..." && | |
273 | files="dir1/file11 dir1/file12 dir2/file21 dir2/file22" && | |
274 | client_verify $files && | |
275 | test_when_finished cleanup_git && | |
6ab1d76c | 276 | git p4 clone --use-client-spec --dest="$git" //depot/dir1 && |
543987bd PW |
277 | git_verify dir1/file11 dir1/file12 |
278 | ' | |
279 | ||
280 | # | |
281 | # submit back, see what happens: five cases | |
282 | # | |
283 | test_expect_success 'subdir clone, submit modify' ' | |
284 | client_view "//depot/... //client/..." && | |
285 | test_when_finished cleanup_git && | |
6ab1d76c | 286 | git p4 clone --use-client-spec --dest="$git" //depot/dir1 && |
543987bd PW |
287 | ( |
288 | cd "$git" && | |
289 | git config git-p4.skipSubmitEdit true && | |
290 | echo line >>dir1/file12 && | |
291 | git add dir1/file12 && | |
292 | git commit -m dir1/file12 && | |
6ab1d76c | 293 | git p4 submit |
543987bd PW |
294 | ) && |
295 | ( | |
296 | cd "$cli" && | |
297 | test_path_is_file dir1/file12 && | |
298 | test_line_count = 2 dir1/file12 | |
299 | ) | |
300 | ' | |
301 | ||
302 | test_expect_success 'subdir clone, submit add' ' | |
303 | client_view "//depot/... //client/..." && | |
304 | test_when_finished cleanup_git && | |
6ab1d76c | 305 | git p4 clone --use-client-spec --dest="$git" //depot/dir1 && |
543987bd PW |
306 | ( |
307 | cd "$git" && | |
308 | git config git-p4.skipSubmitEdit true && | |
309 | echo file13 >dir1/file13 && | |
310 | git add dir1/file13 && | |
311 | git commit -m dir1/file13 && | |
6ab1d76c | 312 | git p4 submit |
543987bd PW |
313 | ) && |
314 | ( | |
315 | cd "$cli" && | |
316 | test_path_is_file dir1/file13 | |
317 | ) | |
318 | ' | |
319 | ||
320 | test_expect_success 'subdir clone, submit delete' ' | |
321 | client_view "//depot/... //client/..." && | |
322 | test_when_finished cleanup_git && | |
6ab1d76c | 323 | git p4 clone --use-client-spec --dest="$git" //depot/dir1 && |
543987bd PW |
324 | ( |
325 | cd "$git" && | |
326 | git config git-p4.skipSubmitEdit true && | |
327 | git rm dir1/file12 && | |
328 | git commit -m "delete dir1/file12" && | |
6ab1d76c | 329 | git p4 submit |
543987bd PW |
330 | ) && |
331 | ( | |
332 | cd "$cli" && | |
333 | test_path_is_missing dir1/file12 | |
334 | ) | |
335 | ' | |
336 | ||
337 | test_expect_success 'subdir clone, submit copy' ' | |
338 | client_view "//depot/... //client/..." && | |
339 | test_when_finished cleanup_git && | |
6ab1d76c | 340 | git p4 clone --use-client-spec --dest="$git" //depot/dir1 && |
543987bd PW |
341 | ( |
342 | cd "$git" && | |
343 | git config git-p4.skipSubmitEdit true && | |
344 | git config git-p4.detectCopies true && | |
345 | cp dir1/file11 dir1/file11a && | |
346 | git add dir1/file11a && | |
347 | git commit -m "copy to dir1/file11a" && | |
6ab1d76c | 348 | git p4 submit |
543987bd PW |
349 | ) && |
350 | ( | |
351 | cd "$cli" && | |
b6ad6dcc PW |
352 | test_path_is_file dir1/file11a && |
353 | test ! -w dir1/file11a | |
543987bd PW |
354 | ) |
355 | ' | |
356 | ||
357 | test_expect_success 'subdir clone, submit rename' ' | |
358 | client_view "//depot/... //client/..." && | |
359 | test_when_finished cleanup_git && | |
6ab1d76c | 360 | git p4 clone --use-client-spec --dest="$git" //depot/dir1 && |
543987bd PW |
361 | ( |
362 | cd "$git" && | |
363 | git config git-p4.skipSubmitEdit true && | |
364 | git config git-p4.detectRenames true && | |
365 | git mv dir1/file13 dir1/file13a && | |
366 | git commit -m "rename dir1/file13 to dir1/file13a" && | |
6ab1d76c | 367 | git p4 submit |
543987bd PW |
368 | ) && |
369 | ( | |
370 | cd "$cli" && | |
371 | test_path_is_missing dir1/file13 && | |
b6ad6dcc PW |
372 | test_path_is_file dir1/file13a && |
373 | test ! -w dir1/file13a | |
543987bd PW |
374 | ) |
375 | ' | |
376 | ||
377 | test_expect_success 'reinit depot' ' | |
378 | ( | |
379 | cd "$cli" && | |
543987bd PW |
380 | rm files && |
381 | p4 delete */* && | |
382 | p4 submit -d "delete all files" && | |
383 | init_depot | |
384 | ) | |
385 | ' | |
386 | ||
42d8c279 PW |
387 | # |
388 | # What happens when two files of the same name are overlayed together? | |
389 | # The last-listed file should take preference. | |
390 | # | |
391 | # //depot | |
392 | # - dir1 | |
393 | # - file11 | |
394 | # - file12 | |
395 | # - filecollide | |
396 | # - dir2 | |
397 | # - file21 | |
398 | # - file22 | |
399 | # - filecollide | |
400 | # | |
401 | test_expect_success 'overlay collision setup' ' | |
402 | client_view "//depot/... //client/..." && | |
403 | ( | |
404 | cd "$cli" && | |
405 | p4 sync && | |
406 | echo dir1/filecollide >dir1/filecollide && | |
407 | p4 add dir1/filecollide && | |
408 | p4 submit -d dir1/filecollide && | |
409 | echo dir2/filecollide >dir2/filecollide && | |
410 | p4 add dir2/filecollide && | |
411 | p4 submit -d dir2/filecollide | |
412 | ) | |
413 | ' | |
414 | ||
415 | test_expect_success 'overlay collision 1 to 2' ' | |
416 | client_view "//depot/dir1/... //client/..." \ | |
417 | "+//depot/dir2/... //client/..." && | |
418 | files="file11 file12 file21 file22 filecollide" && | |
419 | echo dir2/filecollide >actual && | |
420 | client_verify $files && | |
421 | test_cmp actual "$cli"/filecollide && | |
422 | test_when_finished cleanup_git && | |
6ab1d76c | 423 | git p4 clone --use-client-spec --dest="$git" //depot && |
42d8c279 PW |
424 | git_verify $files && |
425 | test_cmp actual "$git"/filecollide | |
426 | ' | |
427 | ||
428 | test_expect_failure 'overlay collision 2 to 1' ' | |
429 | client_view "//depot/dir2/... //client/..." \ | |
430 | "+//depot/dir1/... //client/..." && | |
431 | files="file11 file12 file21 file22 filecollide" && | |
432 | echo dir1/filecollide >actual && | |
433 | client_verify $files && | |
434 | test_cmp actual "$cli"/filecollide && | |
435 | test_when_finished cleanup_git && | |
6ab1d76c | 436 | git p4 clone --use-client-spec --dest="$git" //depot && |
42d8c279 PW |
437 | git_verify $files && |
438 | test_cmp actual "$git"/filecollide | |
439 | ' | |
440 | ||
441 | test_expect_success 'overlay collision delete 2' ' | |
442 | client_view "//depot/... //client/..." && | |
443 | ( | |
444 | cd "$cli" && | |
445 | p4 sync && | |
446 | p4 delete dir2/filecollide && | |
447 | p4 submit -d "remove dir2/filecollide" | |
448 | ) | |
449 | ' | |
450 | ||
451 | # no filecollide, got deleted with dir2 | |
452 | test_expect_failure 'overlay collision 1 to 2, but 2 deleted' ' | |
453 | client_view "//depot/dir1/... //client/..." \ | |
454 | "+//depot/dir2/... //client/..." && | |
455 | files="file11 file12 file21 file22" && | |
456 | client_verify $files && | |
457 | test_when_finished cleanup_git && | |
6ab1d76c | 458 | git p4 clone --use-client-spec --dest="$git" //depot && |
42d8c279 PW |
459 | git_verify $files |
460 | ' | |
461 | ||
462 | test_expect_success 'overlay collision update 1' ' | |
463 | client_view "//depot/dir1/... //client/dir1/..." && | |
464 | ( | |
465 | cd "$cli" && | |
466 | p4 sync && | |
467 | p4 open dir1/filecollide && | |
468 | echo dir1/filecollide update >dir1/filecollide && | |
469 | p4 submit -d "update dir1/filecollide" | |
470 | ) | |
471 | ' | |
472 | ||
473 | # still no filecollide, dir2 still wins with the deletion even though the | |
474 | # change to dir1 is more recent | |
475 | test_expect_failure 'overlay collision 1 to 2, but 2 deleted, then 1 updated' ' | |
476 | client_view "//depot/dir1/... //client/..." \ | |
477 | "+//depot/dir2/... //client/..." && | |
478 | files="file11 file12 file21 file22" && | |
479 | client_verify $files && | |
480 | test_when_finished cleanup_git && | |
6ab1d76c | 481 | git p4 clone --use-client-spec --dest="$git" //depot && |
42d8c279 PW |
482 | git_verify $files |
483 | ' | |
484 | ||
485 | test_expect_success 'overlay collision delete filecollides' ' | |
486 | client_view "//depot/... //client/..." && | |
487 | ( | |
488 | cd "$cli" && | |
489 | p4 sync && | |
490 | p4 delete dir1/filecollide dir2/filecollide && | |
491 | p4 submit -d "remove filecollides" | |
492 | ) | |
493 | ' | |
494 | ||
495 | # | |
496 | # Overlays as part of sync, rather than initial checkout: | |
497 | # 1. add a file in dir1 | |
498 | # 2. sync to include it | |
499 | # 3. add same file in dir2 | |
500 | # 4. sync, make sure content switches as dir2 has priority | |
501 | # 5. add another file in dir1 | |
502 | # 6. sync | |
503 | # 7. add/delete same file in dir2 | |
504 | # 8. sync, make sure it disappears, again dir2 wins | |
505 | # 9. cleanup | |
506 | # | |
507 | # //depot | |
508 | # - dir1 | |
509 | # - file11 | |
510 | # - file12 | |
511 | # - colA | |
512 | # - colB | |
513 | # - dir2 | |
514 | # - file21 | |
515 | # - file22 | |
516 | # - colA | |
517 | # - colB | |
518 | # | |
519 | test_expect_success 'overlay sync: add colA in dir1' ' | |
520 | client_view "//depot/dir1/... //client/dir1/..." && | |
521 | ( | |
522 | cd "$cli" && | |
523 | p4 sync && | |
524 | echo dir1/colA >dir1/colA && | |
525 | p4 add dir1/colA && | |
526 | p4 submit -d dir1/colA | |
527 | ) | |
528 | ' | |
529 | ||
530 | test_expect_success 'overlay sync: initial git checkout' ' | |
531 | client_view "//depot/dir1/... //client/..." \ | |
532 | "+//depot/dir2/... //client/..." && | |
533 | files="file11 file12 file21 file22 colA" && | |
534 | echo dir1/colA >actual && | |
535 | client_verify $files && | |
536 | test_cmp actual "$cli"/colA && | |
6ab1d76c | 537 | git p4 clone --use-client-spec --dest="$git" //depot && |
42d8c279 PW |
538 | git_verify $files && |
539 | test_cmp actual "$git"/colA | |
540 | ' | |
541 | ||
542 | test_expect_success 'overlay sync: add colA in dir2' ' | |
543 | client_view "//depot/dir2/... //client/dir2/..." && | |
544 | ( | |
545 | cd "$cli" && | |
546 | p4 sync && | |
547 | echo dir2/colA >dir2/colA && | |
548 | p4 add dir2/colA && | |
549 | p4 submit -d dir2/colA | |
550 | ) | |
551 | ' | |
552 | ||
553 | test_expect_success 'overlay sync: colA content switch' ' | |
554 | client_view "//depot/dir1/... //client/..." \ | |
555 | "+//depot/dir2/... //client/..." && | |
556 | files="file11 file12 file21 file22 colA" && | |
557 | echo dir2/colA >actual && | |
558 | client_verify $files && | |
559 | test_cmp actual "$cli"/colA && | |
560 | ( | |
561 | cd "$git" && | |
6ab1d76c | 562 | git p4 sync --use-client-spec && |
42d8c279 PW |
563 | git merge --ff-only p4/master |
564 | ) && | |
565 | git_verify $files && | |
566 | test_cmp actual "$git"/colA | |
567 | ' | |
568 | ||
569 | test_expect_success 'overlay sync: add colB in dir1' ' | |
570 | client_view "//depot/dir1/... //client/dir1/..." && | |
571 | ( | |
572 | cd "$cli" && | |
573 | p4 sync && | |
574 | echo dir1/colB >dir1/colB && | |
575 | p4 add dir1/colB && | |
576 | p4 submit -d dir1/colB | |
577 | ) | |
578 | ' | |
579 | ||
580 | test_expect_success 'overlay sync: colB appears' ' | |
581 | client_view "//depot/dir1/... //client/..." \ | |
582 | "+//depot/dir2/... //client/..." && | |
583 | files="file11 file12 file21 file22 colA colB" && | |
584 | echo dir1/colB >actual && | |
585 | client_verify $files && | |
586 | test_cmp actual "$cli"/colB && | |
587 | ( | |
588 | cd "$git" && | |
6ab1d76c | 589 | git p4 sync --use-client-spec && |
42d8c279 PW |
590 | git merge --ff-only p4/master |
591 | ) && | |
592 | git_verify $files && | |
593 | test_cmp actual "$git"/colB | |
594 | ' | |
595 | ||
596 | test_expect_success 'overlay sync: add/delete colB in dir2' ' | |
597 | client_view "//depot/dir2/... //client/dir2/..." && | |
598 | ( | |
599 | cd "$cli" && | |
600 | p4 sync && | |
601 | echo dir2/colB >dir2/colB && | |
602 | p4 add dir2/colB && | |
603 | p4 submit -d dir2/colB && | |
604 | p4 delete dir2/colB && | |
605 | p4 submit -d "delete dir2/colB" | |
606 | ) | |
607 | ' | |
608 | ||
609 | test_expect_success 'overlay sync: colB disappears' ' | |
610 | client_view "//depot/dir1/... //client/..." \ | |
611 | "+//depot/dir2/... //client/..." && | |
612 | files="file11 file12 file21 file22 colA" && | |
613 | client_verify $files && | |
614 | test_when_finished cleanup_git && | |
615 | ( | |
616 | cd "$git" && | |
6ab1d76c | 617 | git p4 sync --use-client-spec && |
42d8c279 PW |
618 | git merge --ff-only p4/master |
619 | ) && | |
620 | git_verify $files | |
621 | ' | |
622 | ||
623 | test_expect_success 'overlay sync: cleanup' ' | |
624 | client_view "//depot/... //client/..." && | |
625 | ( | |
626 | cd "$cli" && | |
627 | p4 sync && | |
628 | p4 delete dir1/colA dir2/colA dir1/colB && | |
629 | p4 submit -d "remove overlay sync files" | |
630 | ) | |
631 | ' | |
632 | ||
633 | # | |
634 | # Overlay tests again, but swapped so dir1 has priority. | |
635 | # 1. add a file in dir1 | |
636 | # 2. sync to include it | |
637 | # 3. add same file in dir2 | |
638 | # 4. sync, make sure content does not switch | |
639 | # 5. add another file in dir1 | |
640 | # 6. sync | |
641 | # 7. add/delete same file in dir2 | |
642 | # 8. sync, make sure it is still there | |
643 | # 9. cleanup | |
644 | # | |
645 | # //depot | |
646 | # - dir1 | |
647 | # - file11 | |
648 | # - file12 | |
649 | # - colA | |
650 | # - colB | |
651 | # - dir2 | |
652 | # - file21 | |
653 | # - file22 | |
654 | # - colA | |
655 | # - colB | |
656 | # | |
657 | test_expect_success 'overlay sync swap: add colA in dir1' ' | |
658 | client_view "//depot/dir1/... //client/dir1/..." && | |
659 | ( | |
660 | cd "$cli" && | |
661 | p4 sync && | |
662 | echo dir1/colA >dir1/colA && | |
663 | p4 add dir1/colA && | |
664 | p4 submit -d dir1/colA | |
665 | ) | |
666 | ' | |
667 | ||
668 | test_expect_success 'overlay sync swap: initial git checkout' ' | |
669 | client_view "//depot/dir2/... //client/..." \ | |
670 | "+//depot/dir1/... //client/..." && | |
671 | files="file11 file12 file21 file22 colA" && | |
672 | echo dir1/colA >actual && | |
673 | client_verify $files && | |
674 | test_cmp actual "$cli"/colA && | |
6ab1d76c | 675 | git p4 clone --use-client-spec --dest="$git" //depot && |
42d8c279 PW |
676 | git_verify $files && |
677 | test_cmp actual "$git"/colA | |
678 | ' | |
679 | ||
680 | test_expect_success 'overlay sync swap: add colA in dir2' ' | |
681 | client_view "//depot/dir2/... //client/dir2/..." && | |
682 | ( | |
683 | cd "$cli" && | |
684 | p4 sync && | |
685 | echo dir2/colA >dir2/colA && | |
686 | p4 add dir2/colA && | |
687 | p4 submit -d dir2/colA | |
688 | ) | |
689 | ' | |
690 | ||
691 | test_expect_failure 'overlay sync swap: colA no content switch' ' | |
692 | client_view "//depot/dir2/... //client/..." \ | |
693 | "+//depot/dir1/... //client/..." && | |
694 | files="file11 file12 file21 file22 colA" && | |
695 | echo dir1/colA >actual && | |
696 | client_verify $files && | |
697 | test_cmp actual "$cli"/colA && | |
698 | ( | |
699 | cd "$git" && | |
6ab1d76c | 700 | git p4 sync --use-client-spec && |
42d8c279 PW |
701 | git merge --ff-only p4/master |
702 | ) && | |
703 | git_verify $files && | |
704 | test_cmp actual "$git"/colA | |
705 | ' | |
706 | ||
707 | test_expect_success 'overlay sync swap: add colB in dir1' ' | |
708 | client_view "//depot/dir1/... //client/dir1/..." && | |
709 | ( | |
710 | cd "$cli" && | |
711 | p4 sync && | |
712 | echo dir1/colB >dir1/colB && | |
713 | p4 add dir1/colB && | |
714 | p4 submit -d dir1/colB | |
715 | ) | |
716 | ' | |
717 | ||
718 | test_expect_success 'overlay sync swap: colB appears' ' | |
719 | client_view "//depot/dir2/... //client/..." \ | |
720 | "+//depot/dir1/... //client/..." && | |
721 | files="file11 file12 file21 file22 colA colB" && | |
722 | echo dir1/colB >actual && | |
723 | client_verify $files && | |
724 | test_cmp actual "$cli"/colB && | |
725 | ( | |
726 | cd "$git" && | |
6ab1d76c | 727 | git p4 sync --use-client-spec && |
42d8c279 PW |
728 | git merge --ff-only p4/master |
729 | ) && | |
730 | git_verify $files && | |
731 | test_cmp actual "$git"/colB | |
732 | ' | |
733 | ||
734 | test_expect_success 'overlay sync swap: add/delete colB in dir2' ' | |
735 | client_view "//depot/dir2/... //client/dir2/..." && | |
736 | ( | |
737 | cd "$cli" && | |
738 | p4 sync && | |
739 | echo dir2/colB >dir2/colB && | |
740 | p4 add dir2/colB && | |
741 | p4 submit -d dir2/colB && | |
742 | p4 delete dir2/colB && | |
743 | p4 submit -d "delete dir2/colB" | |
744 | ) | |
745 | ' | |
746 | ||
747 | test_expect_failure 'overlay sync swap: colB no change' ' | |
748 | client_view "//depot/dir2/... //client/..." \ | |
749 | "+//depot/dir1/... //client/..." && | |
750 | files="file11 file12 file21 file22 colA colB" && | |
751 | echo dir1/colB >actual && | |
752 | client_verify $files && | |
753 | test_cmp actual "$cli"/colB && | |
754 | test_when_finished cleanup_git && | |
755 | ( | |
756 | cd "$git" && | |
6ab1d76c | 757 | git p4 sync --use-client-spec && |
42d8c279 PW |
758 | git merge --ff-only p4/master |
759 | ) && | |
760 | git_verify $files && | |
761 | test_cmp actual "$cli"/colB | |
762 | ' | |
763 | ||
764 | test_expect_success 'overlay sync swap: cleanup' ' | |
765 | client_view "//depot/... //client/..." && | |
766 | ( | |
767 | cd "$cli" && | |
768 | p4 sync && | |
769 | p4 delete dir1/colA dir2/colA dir1/colB && | |
770 | p4 submit -d "remove overlay sync files" | |
771 | ) | |
772 | ' | |
773 | ||
c700b684 PW |
774 | # |
775 | # Rename directories to test quoting in depot-side mappings | |
776 | # //depot | |
777 | # - "dir 1" | |
778 | # - file11 | |
779 | # - file12 | |
780 | # - "dir 2" | |
781 | # - file21 | |
782 | # - file22 | |
783 | # | |
784 | test_expect_success 'rename files to introduce spaces' ' | |
785 | client_view "//depot/... //client/..." && | |
786 | client_verify dir1/file11 dir1/file12 \ | |
787 | dir2/file21 dir2/file22 && | |
788 | ( | |
789 | cd "$cli" && | |
790 | p4 open dir1/... && | |
791 | p4 move dir1/... "dir 1"/... && | |
792 | p4 open dir2/... && | |
793 | p4 move dir2/... "dir 2"/... && | |
794 | p4 submit -d "rename with spaces" | |
795 | ) && | |
796 | client_verify "dir 1/file11" "dir 1/file12" \ | |
797 | "dir 2/file21" "dir 2/file22" | |
798 | ' | |
799 | ||
ecb7cf98 | 800 | test_expect_success 'quotes on lhs only' ' |
c700b684 PW |
801 | client_view "\"//depot/dir 1/...\" //client/cdir1/..." && |
802 | files="cdir1/file11 cdir1/file12" && | |
803 | client_verify $files && | |
804 | test_when_finished cleanup_git && | |
6ab1d76c | 805 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
806 | client_verify $files |
807 | ' | |
808 | ||
ecb7cf98 | 809 | test_expect_success 'quotes on both sides' ' |
c700b684 PW |
810 | client_view "\"//depot/dir 1/...\" \"//client/cdir 1/...\"" && |
811 | client_verify "cdir 1/file11" "cdir 1/file12" && | |
812 | test_when_finished cleanup_git && | |
6ab1d76c | 813 | git p4 clone --use-client-spec --dest="$git" //depot && |
c700b684 PW |
814 | git_verify "cdir 1/file11" "cdir 1/file12" |
815 | ' | |
816 | ||
817 | test_expect_success 'kill p4d' ' | |
818 | kill_p4d | |
819 | ' | |
820 | ||
821 | test_done |