3 test_description
='git p4 locked file behavior'
7 test_expect_success
'start p4d' '
12 # http://www.perforce.com/perforce/doc.current/manuals/p4sag/03_superuser.html#1088563
13 # for suggestions on how to configure "sitewide pessimistic locking"
14 # where only one person can have a file open for edit at a time.
15 test_expect_success
'init depot' '
18 echo "TypeMap: +l //depot/..." | p4 typemap -i &&
21 p4 submit -d "add file1"
25 test_expect_success
'edit with lock not taken' '
26 test_when_finished cleanup_git &&
27 git p4 clone --dest="$git" //depot &&
32 git commit -m "line2 in file1" &&
33 git config git-p4.skipSubmitEdit true &&
38 test_expect_success
'add with lock not taken' '
39 test_when_finished cleanup_git &&
40 git p4 clone --dest="$git" //depot &&
43 echo line1 >>add-lock-not-taken &&
44 git add add-lock-not-taken &&
45 git commit -m "add add-lock-not-taken" &&
46 git config git-p4.skipSubmitEdit true &&
47 git p4 submit --verbose
51 lock_in_another_client
() {
52 # build a different client
53 cli2
="$TRASH_DIRECTORY/cli2" &&
55 test_when_finished
"p4 client -f -d client2 && rm -rf \"$cli2\"" &&
60 client_view
"//depot/... //client2/..." &&
66 test_expect_failure
'edit with lock taken' '
67 lock_in_another_client &&
68 test_when_finished cleanup_git &&
69 test_when_finished "cd \"$cli\" && p4 sync -f file1" &&
70 git p4 clone --dest="$git" //depot &&
75 git commit -m "line3 in file1" &&
76 git config git-p4.skipSubmitEdit true &&
77 git p4 submit --verbose
81 test_expect_failure
'delete with lock taken' '
82 lock_in_another_client &&
83 test_when_finished cleanup_git &&
84 test_when_finished "cd \"$cli\" && p4 sync -f file1" &&
85 git p4 clone --dest="$git" //depot &&
89 git commit -m "delete file1" &&
90 git config git-p4.skipSubmitEdit true &&
91 git p4 submit --verbose
95 test_expect_failure
'chmod with lock taken' '
96 lock_in_another_client &&
97 test_when_finished cleanup_git &&
98 test_when_finished "cd \"$cli\" && p4 sync -f file1" &&
99 git p4 clone --dest="$git" //depot &&
104 git commit -m "chmod +x file1" &&
105 git config git-p4.skipSubmitEdit true &&
106 git p4 submit --verbose
110 test_expect_success
'copy with lock taken' '
111 lock_in_another_client &&
112 test_when_finished cleanup_git &&
113 test_when_finished "cd \"$cli\" && p4 revert file2 && rm -f file2" &&
114 git p4 clone --dest="$git" //depot &&
119 git commit -m "cp file1 to file2" &&
120 git config git-p4.skipSubmitEdit true &&
121 git config git-p4.detectCopies true &&
122 git p4 submit --verbose
126 test_expect_failure
'move with lock taken' '
127 lock_in_another_client &&
128 test_when_finished cleanup_git &&
129 test_when_finished "cd \"$cli\" && p4 sync file1 && rm -f file2" &&
130 git p4 clone --dest="$git" //depot &&
133 git mv file1 file3 &&
134 git commit -m "mv file1 to file3" &&
135 git config git-p4.skipSubmitEdit true &&
136 git config git-p4.detectRenames true &&
137 git p4 submit --verbose