]> Tony Duckles's Git Repositories (git.nynim.org) - svn2svn.git/blob - tests/make-ref-repo.sh
Fix keep_revnum vs source_start_rev handling
[svn2svn.git] / tests / make-ref-repo.sh
1 #!/bin/bash
2 # Create a reference repo with both /trunk and /branches history
3
4 show_last_commit() {
5 LOG=$(svn log -l1 $REPOURL)
6 revision=$(echo "$LOG" | head -n 2 | tail -n 1| cut -d \| -f 1)
7 comment=$(echo "$LOG" | head -n 4 | tail -n 1)
8 _WC="${WC//\//\\/}"
9 if [ -x "$WC" ]; then
10 len=$(expr ${#REPOURL} + 7)
11 url=$(svn info "$WC" | grep "URL:" | cut -c$len-)
12 url="($url)"
13 fi
14 printf "%-6s%-22s%s\n" "$revision" "$url" "$comment"
15 }
16
17 svn_commit() {
18 svn ci -q -m "$1" $2
19 svn up -q
20 show_last_commit
21 }
22
23
24 PWD=$(pwd)
25 REPO="$PWD/_repo_ref"
26 REPOURL=$(echo "file://$REPO" | sed 's/\ /%20/g')
27 WC="$PWD/_wc_ref"
28
29 # Init repo
30 rm -rf "$REPO" "$WC"
31 echo "Creating _repo_ref..."
32 svnadmin create "$REPO"
33 svn mkdir -q -m "Add /trunk" $REPOURL/trunk
34 show_last_commit
35 svn mkdir -q -m "Add /branches" $REPOURL/branches
36 show_last_commit
37 TRUNK="$REPOURL/trunk"
38 svn co -q $TRUNK "$WC"
39 cd "$WC"
40
41 # Initial Population
42 mkdir -p "$WC/Module/ProjectA"
43 echo "Module/ProjectA/FileA1.txt (Initial)" >> "$WC/Module/ProjectA/FileA1.txt"
44 echo "Module/ProjectA/FileA2.txt (Initial)" >> "$WC/Module/ProjectA/FileA2.txt"
45 svn -q add "$WC/Module"
46 svn propset -q desc "FileA1.txt" "$WC/Module/ProjectA/FileA1.txt"
47 svn propset -q desc "FileA2.txt" "$WC/Module/ProjectA/FileA2.txt"
48 svn_commit "Initial population"
49
50 # Test #1: Add new file
51 # * Test simple copy-from branch
52 # * Test propset
53 BRANCH="$REPOURL/branches/test1"
54 svn copy -q -m "Create branch" $TRUNK $BRANCH
55 svn switch -q $BRANCH
56 show_last_commit
57 mkdir -p "$WC/Module/ProjectB"
58 echo "Module/ProjectB/FileB1.txt (Test 1)" >> "$WC/Module/ProjectB/FileB1.txt"
59 svn add -q "$WC/Module/ProjectB"
60 svn propset -q filename FileB1.txt "$WC/Module/ProjectB/FileB1.txt"
61 svn_commit "Test 1: Add Module/ProjectB"
62 svn switch -q $TRUNK
63 svn merge -q $BRANCH
64 svn ci -q --with-revprop 'testprop=Test 1 message' -m "Test 1: Add Module/ProjectB"
65 svn up -q
66 show_last_commit
67
68 # Empty commit message
69 echo "Module/ProjectB/FileB1.txt (Test 1.1)" >> "$WC/Module/ProjectB/FileB1.txt"
70 svn_commit ""
71
72 # Test #2: Rename files
73 # * Test rename support
74 # * Test committing rename in two different branch commits: first deletion, then add
75 # * Test props from copy-from file carry forward to target
76 BRANCH="$REPOURL/branches/test2"
77 svn copy -q -m "Create branch" $TRUNK $BRANCH
78 svn switch -q $BRANCH
79 show_last_commit
80 svn mv -q Module/ProjectA/FileA2.txt Module/ProjectB/FileB2.txt
81 echo "Module/ProjectB/FileB2.txt (Test 2)" >> "$WC/Module/ProjectB/FileB2.txt"
82 svn_commit "Test 2: Rename Module/ProjectA/FileA2.txt -> Module/ProjectB/FileB2.txt (part 1 of 2)" Module/ProjectA
83 svn_commit "Test 2: Rename Module/ProjectA/FileA2.txt -> Module/ProjectB/FileB2.txt (part 2 of 2)" Module/ProjectB
84 svn switch -q $TRUNK
85 svn merge -q $BRANCH
86 svn_commit "Test 2: Rename Module/ProjectA/FileA2.txt -> Module/ProjectB/FileB3.txt"
87
88 # Test #3: Verify rename
89 # * Test svn:mergeinfo-only change
90 BRANCH="$REPOURL/branches/test3"
91 svn copy -q -m "Create branch" $TRUNK $BRANCH
92 svn switch -q $BRANCH
93 show_last_commit
94 echo "Module/ProjectB/FileB2.txt (Test 3)" >> "$WC/Module/ProjectB/FileB2.txt"
95 svn propset -q filename FileB2.txt "$WC/Module/ProjectB/FileB2.txt"
96 svn propset -q 'svn:mergeinfo' '/branches/foo/Module/ProjectB/FileB1.txt:5' "$WC/Module/ProjectB/FileB1.txt"
97 svn propset -q 'svn:mergeinfo' '/branches/foo/Module/ProjectB/FileB2.txt:5' "$WC/Module/ProjectB/FileB2.txt"
98 svn_commit "Test 3: Verify Module/ProjectB/FileB2.txt"
99 svn switch -q $TRUNK
100 svn merge -q $BRANCH
101 svn_commit "Test 3: Verify Module/ProjectB/FileB2.txt"
102
103 # Test #4: Replace files
104 # * Test replace support
105 BRANCH="$REPOURL/branches/test4"
106 svn copy -q -m "Create branch" $TRUNK $BRANCH
107 svn switch -q $BRANCH
108 show_last_commit
109 svn rm -q Module/ProjectA/FileA1.txt
110 echo "Module/ProjectA/FileA1.txt (Test 4 - Replaced)" >> "$WC/Module/ProjectA/FileA1.txt"
111 svn add -q Module/ProjectA/FileA1.txt
112 svn_commit "Test 4: Replace Module/ProjectA/FileA1.txt"
113 svn switch -q $TRUNK
114 svn merge -q $BRANCH
115 svn_commit "Test 4: Replace Module/ProjectA/FileA1.txt"
116
117 # Test #5: Rename files + folders
118 # * Test rename support
119 # * Create complex find-ancestors case, where files are renamed within a renamed folder on a branch
120 # * Test propset and propdel
121 BRANCH="$REPOURL/branches/test5"
122 svn copy -q -m "Create branch" $TRUNK $BRANCH
123 svn switch -q $BRANCH
124 show_last_commit
125 svn mv -q Module/ProjectB Module/ProjectC
126 svn mv -q Module/ProjectC/FileB1.txt Module/ProjectC/FileC1.txt
127 echo "Module/ProjectC/FileC1.txt (Test 5)" >> "$WC/Module/ProjectC/FileC1.txt"
128 svn propdel -q filename "$WC/Module/ProjectC/FileC1.txt"
129 svn propset -q desc 'This is a long string
130 broken on two lines...' "$WC/Module/ProjectC/FileC1.txt"
131 svn mv -q Module/ProjectC/FileB2.txt Module/ProjectC/FileC2.txt
132 svn propset -q filename FileC2.txt "$WC/Module/ProjectC/FileC2.txt"
133 echo "Module/ProjectC/FileC2.txt (Test 5)" >> "$WC/Module/ProjectC/FileC2.txt"
134 svn_commit "Test 5: Rename Module/ProjectB -> Module/ProjectC"
135 svn switch -q $TRUNK
136 svn merge -q $BRANCH
137 svn_commit "Test 5: Rename Module/ProjectB -> Module/ProjectC"
138
139 # Test #6: Verify rename
140 BRANCH="$REPOURL/branches/test6"
141 svn copy -q -m "Create branch" $TRUNK $BRANCH
142 svn switch -q $BRANCH
143 show_last_commit
144 echo "Module/ProjectC/FileC1.txt (Test 6)" >> "$WC/Module/ProjectC/FileC1.txt"
145 echo "Module/ProjectC/FileC2.txt (Test 6)" >> "$WC/Module/ProjectC/FileC2.txt"
146 svn_commit "Test 6: Verify Module/ProjectC/FileC*.txt"
147 svn switch -q $TRUNK
148 svn merge -q $BRANCH
149 svn_commit "Test 6: Verify Module/ProjectC/FileC*.txt"
150
151 # Test #7: Rename files
152 # * Test rename support
153 # * Rename multiple files in the same folder
154 BRANCH="$REPOURL/branches/test7"
155 svn copy -q -m "Create branch" $TRUNK $BRANCH
156 svn switch -q $BRANCH
157 show_last_commit
158 svn mv -q Module/ProjectC/FileC1.txt Module/ProjectC/FileC3.txt
159 echo "Module/ProjectC/FileC3.txt (Test 7)" >> "$WC/Module/ProjectC/FileC3.txt"
160 svn mv -q Module/ProjectC/FileC2.txt Module/ProjectC/FileC4.txt
161 echo "Module/ProjectC/FileC4.txt (Test 7)" >> "$WC/Module/ProjectC/FileC4.txt"
162 svn_commit "Test 7: Rename Module/ProjectC/FileC*.txt"
163 svn switch -q $TRUNK
164 svn merge -q $BRANCH
165 svn_commit "Test 7: Rename Module/ProjectC/FileC*.txt"
166
167 # Test #8: Verify rename
168 BRANCH="$REPOURL/branches/test8"
169 svn copy -q -m "Create branch" $TRUNK $BRANCH
170 svn switch -q $BRANCH
171 show_last_commit
172 echo "Module/ProjectC/FileC3.txt (Test 8)" >> "$WC/Module/ProjectC/FileC3.txt"
173 echo "Module/ProjectC/FileC4.txt (Test 8)" >> "$WC/Module/ProjectC/FileC4.txt"
174 svn_commit "Test 8: Verify Module/ProjectC/FileC*.txt"
175 svn switch -q $TRUNK
176 svn merge -q $BRANCH
177 svn_commit "Test 8: Verify Module/ProjectC/FileC*.txt"
178
179 # Test #9: Copy from older revision
180 svn copy -q -r 8 $TRUNK/Module/ProjectA/FileA2.txt@8 "$WC/Module/ProjectA/FileA2.txt"
181 svn propdel -q svn:mergeinfo Module/ProjectA/FileA2.txt
182 svn_commit "Test 9: Restore Module/ProjectA/FileA2.txt"
183
184 # Test #10: Verify copy
185 BRANCH="$REPOURL/branches/test10"
186 svn copy -q -m "Create branch" $TRUNK $BRANCH
187 svn switch -q $BRANCH
188 show_last_commit
189 echo "Module/ProjectA/FileA2.txt (Test 10)" >> "$WC/Module/ProjectA/FileA2.txt"
190 svn_commit "Test 10: Verify Module/ProjectA/FileA2.txt"
191 svn switch -q $TRUNK
192 svn merge -q $BRANCH
193 svn_commit "Test 10: Verify Module/ProjectA/FileA2.txt"
194
195 # Test #11: Rename files + folders, multiple chained renames
196 # * Test rename support
197 # * Create complicated find-ancestors case, where files/folders are renamed multiple times on branch
198 BRANCH="$REPOURL/branches/test11"
199 svn copy -q -m "Create branch" $TRUNK $BRANCH
200 svn switch -q $BRANCH
201 show_last_commit
202 svn mv -q Module/ProjectC Module/ProjectD
203 svn mv -q Module/ProjectD/FileC3.txt Module/ProjectD/FileD1.txt
204 echo "Module/ProjectD/FileD1.txt (Test 11)" >> "$WC/Module/ProjectD/FileD1.txt"
205 svn mv -q Module/ProjectD/FileC4.txt Module/ProjectD/FileD2.txt
206 echo "Module/ProjectD/FileD2.txt (Test 11)" >> "$WC/Module/ProjectD/FileD2.txt"
207 svn_commit "Test 11: Rename Module/ProjectC -> Module/ProjectD (part 1 of 2)" Module/ProjectC Module/ProjectD/FileC3.txt Module/ProjectD/FileC4.txt
208 svn_commit "Test 11: Rename Module/ProjectC -> Module/ProjectD (part 2 of 2)"
209 BRANCH="$REPOURL/branches/test11-1"
210 svn copy -q -m "Create branch" $TRUNK $BRANCH
211 svn switch -q $BRANCH
212 show_last_commit
213 svn merge -q $REPOURL/branches/test11
214 svn_commit "Test 11: Re-branch"
215 svn mv -q Module/ProjectD Module/ProjectE
216 svn mv -q Module/ProjectE/FileD1.txt Module/ProjectE/FileE1.txt
217 echo "Module/ProjectE/FileE1.txt (Test 11-1)" >> "$WC/Module/ProjectE/FileE1.txt"
218 svn mv -q Module/ProjectE/FileD2.txt Module/ProjectE/FileE2.txt
219 echo "Module/ProjectE/FileE2.txt (Test 11-1)" >> "$WC/Module/ProjectE/FileE2.txt"
220 svn_commit "Test 11: Rename Module/ProjectD -> Module/ProjectE (part 1 of 2)" Module/ProjectD Module/ProjectE/FileD1.txt Module/ProjectE/FileD2.txt
221 svn_commit "Test 11: Rename Module/ProjectD -> Module/ProjectE (part 2 of 2)"
222 svn switch -q $TRUNK
223 svn merge -q $BRANCH
224 svn_commit "Test 11: Rename Module/ProjectC -> Module/ProjectE"
225
226 # Test #12: Verify renames
227 BRANCH="$REPOURL/branches/test12"
228 svn copy -q -m "Create branch" $TRUNK $BRANCH
229 svn switch -q $BRANCH
230 show_last_commit
231 echo "Module/ProjectE/FileE1.txt (Test 12)" >> "$WC/Module/ProjectE/FileE1.txt"
232 echo "Module/ProjectE/FileE2.txt (Test 12)" >> "$WC/Module/ProjectE/FileE2.txt"
233 svn_commit "Test 12: Verify Module/ProjectE/FileE*.txt"
234 svn switch -q $TRUNK
235 svn merge -q $BRANCH
236 svn_commit "Test 12: Verify Module/ProjectE/FileE*.txt"
237
238 # Test #13: Replaces and add's inside a parent renamed folder.
239 BRANCH="$REPOURL/branches/test13"
240 svn copy -q -m "Create branch" $TRUNK $BRANCH
241 svn switch -q $BRANCH
242 show_last_commit
243 svn copy -q Module/ProjectA Module/ProjectB
244 echo "Module/ProjectB/FileA1.txt (Test 13-1)" >> "$WC/Module/ProjectB/FileA1.txt"
245 echo "Module/ProjectB/FileA2.txt (Test 13-1)" >> "$WC/Module/ProjectB/FileA2.txt"
246 svn_commit "Test 13: Copy Module/ProjectA -> Module/ProjectB"
247 svn mv -q Module/ProjectB/FileA1.txt Module/ProjectB/FileB1.txt
248 echo "Module/ProjectB/FileB1.txt (Test 13-2)" >> "$WC/Module/ProjectB/FileB1.txt"
249 svn mv -q Module/ProjectB/FileA2.txt Module/ProjectB/FileB2.txt
250 echo "Module/ProjectB/FileB2.txt (Test 13-2)" >> "$WC/Module/ProjectB/FileB2.txt"
251 svn_commit "Test 13: Rename Module/ProjectB/FileA*.txt -> FileB*.txt"
252 svn copy -q Module/ProjectB/FileB2.txt Module/ProjectB/FileB3.txt
253 echo "Module/ProjectB/FileB3.txt (Test 13-3)" >> "$WC/Module/ProjectB/FileB3.txt"
254 svn rm -q Module/ProjectB/FileB1.txt
255 echo "Module/ProjectB/FileB1.txt (Test 13-3 - Replaced)" >> "$WC/Module/ProjectB/FileB1.txt"
256 svn add -q Module/ProjectB/FileB1.txt
257 svn_commit "Test 13: Edits to Module/ProjectB/FileB*.txt"
258 svn switch -q $TRUNK
259 svn merge -q $BRANCH
260 svn_commit "Test 13: Create Module/ProjectB from Module/ProjectA"
261
262 # Test #14: Verify renames
263 BRANCH="$REPOURL/branches/test14"
264 svn copy -q -m "Create branch" $TRUNK $BRANCH
265 svn switch -q $BRANCH
266 show_last_commit
267 echo "Module/ProjectB/FileB1.txt (Test 14)" >> "$WC/Module/ProjectB/FileB1.txt"
268 echo "Module/ProjectB/FileB2.txt (Test 14)" >> "$WC/Module/ProjectB/FileB2.txt"
269 echo "Module/ProjectB/FileB3.txt (Test 14)" >> "$WC/Module/ProjectB/FileB3.txt"
270 svn_commit "Test 14: Verify Module/ProjectB/FileB*.txt"
271 svn switch -q $TRUNK
272 svn merge -q $BRANCH
273 svn_commit "Test 14: Verify Module/ProjectB/FileB*.txt"
274
275 # Test #15: Replace copy-from
276 BRANCH="$REPOURL/branches/test15"
277 svn copy -q -m "Create branch" $TRUNK $BRANCH
278 svn switch -q $BRANCH
279 show_last_commit
280 svn rm -q Module/ProjectB/FileB2.txt
281 svn copy -q -r 22 $TRUNK/Module/ProjectC/FileC1.txt@22 Module/ProjectB/FileB2.txt
282 echo "Module/ProjectB/FileB2.txt (Test 15 - Replaced)" >> "$WC/Module/ProjectB/FileB2.txt"
283 svn_commit "Test 15: Replace Module/ProjectB/FileB2.txt from earlier Module/ProjectC/FileC1.txt"
284 svn switch -q $TRUNK
285 svn merge -q $BRANCH
286 svn_commit "Test 15: Replace Module/ProjectB/FileB2.txt from earlier Module/ProjectC/FileC1.txt"
287
288 # Test #16: Verify replace
289 BRANCH="$REPOURL/branches/test16"
290 svn copy -q -m "Create branch" $TRUNK $BRANCH
291 svn switch -q $BRANCH
292 show_last_commit
293 echo "Module/ProjectB/FileB2.txt (Test 16)" >> "$WC/Module/ProjectB/FileB2.txt"
294 svn_commit "Test 16: Verify Module/ProjectB/FileB2.txt"
295 svn switch -q $TRUNK
296 svn merge -q $BRANCH
297 svn_commit "Test 16: Verify Module/ProjectB/FileB2.txt"
298
299 # Test #17: Copy-from replaces and add's inside top-level initial-add folder
300 BRANCH="$REPOURL/branches/test17"
301 svn copy -q -m "Create branch" $TRUNK $BRANCH
302 svn switch -q $BRANCH
303 show_last_commit
304 svn mkdir -q Module2
305 svn copy -q Module/ProjectB Module2/ProjectB
306 echo "Module2/ProjectB/FileB1.txt (Test 17-1)" >> "$WC/Module2/ProjectB/FileB1.txt"
307 echo "Module2/ProjectB/FileB2.txt (Test 17-1)" >> "$WC/Module2/ProjectB/FileB2.txt"
308 echo "Module2/ProjectB/FileB3.txt (Test 17-1)" >> "$WC/Module2/ProjectB/FileB3.txt"
309 svn_commit "Test 17: Copy Module/ProjectB -> Module2/ProjectB"
310 svn rm -q Module2/ProjectB/FileB1.txt
311 svn copy -q -r 22 $TRUNK/Module/ProjectC/FileC2.txt@22 Module2/ProjectB/FileB1.txt
312 echo "Module2/ProjectB/FileB1.txt (Test 17-2)" >> "$WC/Module2/ProjectB/FileB1.txt"
313 svn_commit "Test 17: Replace Module2/ProjectB/FileB1.txt from earlier Module/ProjectC/FileC2.txt"
314 svn switch -q $TRUNK
315 svn merge -q $BRANCH
316 svn_commit "Test 17: Create Module2/ProjectB from Module/ProjectB"
317
318 # Test #18: File/folder names with spaces, %, and @ chars, to test URL encoding
319 BRANCH="$REPOURL/branches/test18"
320 svn copy -q -m "Create branch" $TRUNK $BRANCH
321 svn switch -q $BRANCH
322 show_last_commit
323 svn mkdir -q "Module2/My Folder"
324 echo "Module2/My Folder/file@2x.txt" >> "$WC/Module2/My Folder/file@2x.txt"
325 echo "Module2/My Folder/%some_file.txt" >> "$WC/Module2/My Folder/%some_file.txt"
326 echo "Module2/My Folder/file%20test.txt" >> "$WC/Module2/My Folder/file%20test.txt"
327 echo "Module2/My Folder/file test2.txt" >> "$WC/Module2/My Folder/file test2.txt"
328 svn add -q "Module2/My Folder/file@2x.txt@"
329 svn add -q "Module2/My Folder/%some_file.txt"
330 svn add -q "Module2/My Folder/file%20test.txt"
331 svn add -q "Module2/My Folder/file test2.txt"
332 svn propset -q desc "file@2x" "$WC/Module2/My Folder/file@2x.txt@"
333 svn propset -q desc "%some_file" "$WC/Module2/My Folder/%some_file.txt"
334 svn propset -q desc "file%20test" "$WC/Module2/My Folder/file%20test.txt"
335 svn propset -q desc "file test2" "$WC/Module2/My Folder/file test2.txt"
336 svn_commit "Test 18: Add Module2/My Folder/*.txt"
337 svn switch -q $TRUNK
338 svn merge -q $BRANCH
339 svn_commit "Test 18: Add Module2/My Folder/*.txt"
340
341 # Clean-up
342 echo "Cleaning-up..."
343 rm -rf "$WC"