]> Tony Duckles's Git Repositories (git.nynim.org) - svn2svn.git/blob - tests/make-ref-repo.sh
Fix a place in find_svn_ancestors() which should've been using is_child_path().
[svn2svn.git] / tests / make-ref-repo.sh
1 #!/bin/sh
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="file://$REPO"
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 BRANCH="$REPOURL/branches/test3"
90 svn copy -q -m "Create branch" $TRUNK $BRANCH
91 svn switch -q $BRANCH
92 show_last_commit
93 echo "Module/ProjectB/FileB2.txt (Test 3)" >> $WC/Module/ProjectB/FileB2.txt
94 svn propset -q filename FileB2.txt $WC/Module/ProjectB/FileB2.txt
95 svn_commit "Test 3: Verify Module/ProjectB/FileB2.txt"
96 svn switch -q $TRUNK
97 svn merge -q $BRANCH
98 svn_commit "Test 3: Verify Module/ProjectB/FileB2.txt"
99
100 # Test #4: Replace files
101 # * Test replace support
102 BRANCH="$REPOURL/branches/test4"
103 svn copy -q -m "Create branch" $TRUNK $BRANCH
104 svn switch -q $BRANCH
105 show_last_commit
106 svn rm -q Module/ProjectA/FileA1.txt
107 echo "Module/ProjectA/FileA1.txt (Test 4 - Replaced)" >> $WC/Module/ProjectA/FileA1.txt
108 svn add -q Module/ProjectA/FileA1.txt
109 svn_commit "Test 4: Replace Module/ProjectA/FileA1.txt"
110 svn switch -q $TRUNK
111 svn merge -q $BRANCH
112 svn_commit "Test 4: Replace Module/ProjectA/FileA1.txt"
113
114 # Test #5: Rename files + folders
115 # * Test rename support
116 # * Create complex find-ancestors case, where files are renamed within a renamed folder on a branch
117 # * Test propset and propdel
118 BRANCH="$REPOURL/branches/test5"
119 svn copy -q -m "Create branch" $TRUNK $BRANCH
120 svn switch -q $BRANCH
121 show_last_commit
122 svn mv -q Module/ProjectB Module/ProjectC
123 svn mv -q Module/ProjectC/FileB1.txt Module/ProjectC/FileC1.txt
124 echo "Module/ProjectC/FileC1.txt (Test 5)" >> $WC/Module/ProjectC/FileC1.txt
125 svn propdel -q filename $WC/Module/ProjectC/FileC1.txt
126 svn propset -q desc 'This is a long string
127 broken on two lines...' $WC/Module/ProjectC/FileC1.txt
128 svn mv -q Module/ProjectC/FileB2.txt Module/ProjectC/FileC2.txt
129 svn propset -q filename FileC2.txt $WC/Module/ProjectC/FileC2.txt
130 echo "Module/ProjectC/FileC2.txt (Test 5)" >> $WC/Module/ProjectC/FileC2.txt
131 svn_commit "Test 5: Rename Module/ProjectB -> Module/ProjectC"
132 svn switch -q $TRUNK
133 svn merge -q $BRANCH
134 svn_commit "Test 5: Rename Module/ProjectB -> Module/ProjectC"
135
136 # Test #6: Verify rename
137 BRANCH="$REPOURL/branches/test6"
138 svn copy -q -m "Create branch" $TRUNK $BRANCH
139 svn switch -q $BRANCH
140 show_last_commit
141 echo "Module/ProjectC/FileC1.txt (Test 6)" >> $WC/Module/ProjectC/FileC1.txt
142 echo "Module/ProjectC/FileC2.txt (Test 6)" >> $WC/Module/ProjectC/FileC2.txt
143 svn_commit "Test 6: Verify Module/ProjectC/FileC*.txt"
144 svn switch -q $TRUNK
145 svn merge -q $BRANCH
146 svn_commit "Test 6: Verify Module/ProjectC/FileC*.txt"
147
148 # Test #7: Rename files
149 # * Test rename support
150 # * Rename multiple files in the same folder
151 BRANCH="$REPOURL/branches/test7"
152 svn copy -q -m "Create branch" $TRUNK $BRANCH
153 svn switch -q $BRANCH
154 show_last_commit
155 svn mv -q Module/ProjectC/FileC1.txt Module/ProjectC/FileC3.txt
156 echo "Module/ProjectC/FileC3.txt (Test 7)" >> $WC/Module/ProjectC/FileC3.txt
157 svn mv -q Module/ProjectC/FileC2.txt Module/ProjectC/FileC4.txt
158 echo "Module/ProjectC/FileC4.txt (Test 7)" >> $WC/Module/ProjectC/FileC4.txt
159 svn_commit "Test 7: Rename Module/ProjectC/FileC*.txt"
160 svn switch -q $TRUNK
161 svn merge -q $BRANCH
162 svn_commit "Test 7: Rename Module/ProjectC/FileC*.txt"
163
164 # Test #8: Verify rename
165 BRANCH="$REPOURL/branches/test8"
166 svn copy -q -m "Create branch" $TRUNK $BRANCH
167 svn switch -q $BRANCH
168 show_last_commit
169 echo "Module/ProjectC/FileC3.txt (Test 8)" >> $WC/Module/ProjectC/FileC3.txt
170 echo "Module/ProjectC/FileC4.txt (Test 8)" >> $WC/Module/ProjectC/FileC4.txt
171 svn_commit "Test 8: Verify Module/ProjectC/FileC*.txt"
172 svn switch -q $TRUNK
173 svn merge -q $BRANCH
174 svn_commit "Test 8: Verify Module/ProjectC/FileC*.txt"
175
176 # Test #9: Copy from older revision
177 svn copy -q -r 8 $TRUNK/Module/ProjectA/FileA2.txt@8 $WC/Module/ProjectA/FileA2.txt
178 svn propdel -q svn:mergeinfo Module/ProjectA/FileA2.txt
179 svn_commit "Test 9: Restore Module/ProjectA/FileA2.txt"
180
181 # Test #10: Verify copy
182 BRANCH="$REPOURL/branches/test10"
183 svn copy -q -m "Create branch" $TRUNK $BRANCH
184 svn switch -q $BRANCH
185 show_last_commit
186 echo "Module/ProjectA/FileA2.txt (Test 10)" >> $WC/Module/ProjectA/FileA2.txt
187 svn_commit "Test 10: Verify Module/ProjectA/FileA2.txt"
188 svn switch -q $TRUNK
189 svn merge -q $BRANCH
190 svn_commit "Test 10: Verify Module/ProjectA/FileA2.txt"
191
192 # Test #11: Rename files + folders, multiple chained renames
193 # * Test rename support
194 # * Create complicated find-ancestors case, where files/folders are renamed multiple times on branch
195 BRANCH="$REPOURL/branches/test11"
196 svn copy -q -m "Create branch" $TRUNK $BRANCH
197 svn switch -q $BRANCH
198 show_last_commit
199 svn mv -q Module/ProjectC Module/ProjectD
200 svn mv -q Module/ProjectD/FileC3.txt Module/ProjectD/FileD1.txt
201 echo "Module/ProjectD/FileD1.txt (Test 11)" >> $WC/Module/ProjectD/FileD1.txt
202 svn mv -q Module/ProjectD/FileC4.txt Module/ProjectD/FileD2.txt
203 echo "Module/ProjectD/FileD2.txt (Test 11)" >> $WC/Module/ProjectD/FileD2.txt
204 svn_commit "Test 11: Rename Module/ProjectC -> Module/ProjectD (part 1 of 2)" Module/ProjectC Module/ProjectD/FileC3.txt Module/ProjectD/FileC4.txt
205 svn_commit "Test 11: Rename Module/ProjectC -> Module/ProjectD (part 2 of 2)"
206 BRANCH="$REPOURL/branches/test11-1"
207 svn copy -q -m "Create branch" $TRUNK $BRANCH
208 svn switch -q $BRANCH
209 show_last_commit
210 svn merge -q $REPOURL/branches/test11
211 svn_commit "Test 11: Re-branch"
212 svn mv -q Module/ProjectD Module/ProjectE
213 svn mv -q Module/ProjectE/FileD1.txt Module/ProjectE/FileE1.txt
214 echo "Module/ProjectE/FileE1.txt (Test 11-1)" >> $WC/Module/ProjectE/FileE1.txt
215 svn mv -q Module/ProjectE/FileD2.txt Module/ProjectE/FileE2.txt
216 echo "Module/ProjectE/FileE2.txt (Test 11-1)" >> $WC/Module/ProjectE/FileE2.txt
217 svn_commit "Test 11: Rename Module/ProjectD -> Module/ProjectE (part 1 of 2)" Module/ProjectD Module/ProjectE/FileD1.txt Module/ProjectE/FileD2.txt
218 svn_commit "Test 11: Rename Module/ProjectD -> Module/ProjectE (part 2 of 2)"
219 svn switch -q $TRUNK
220 svn merge -q $BRANCH
221 svn_commit "Test 11: Rename Module/ProjectC -> Module/ProjectE"
222
223 # Test #12: Verify renames
224 BRANCH="$REPOURL/branches/test12"
225 svn copy -q -m "Create branch" $TRUNK $BRANCH
226 svn switch -q $BRANCH
227 show_last_commit
228 echo "Module/ProjectE/FileE1.txt (Test 12)" >> $WC/Module/ProjectE/FileE1.txt
229 echo "Module/ProjectE/FileE2.txt (Test 12)" >> $WC/Module/ProjectE/FileE2.txt
230 svn_commit "Test 12: Verify Module/ProjectE/FileE*.txt"
231 svn switch -q $TRUNK
232 svn merge -q $BRANCH
233 svn_commit "Test 12: Verify Module/ProjectE/FileE*.txt"
234
235 # Test #13: Replaces and add's inside a parent renamed folder.
236 BRANCH="$REPOURL/branches/test13"
237 svn copy -q -m "Create branch" $TRUNK $BRANCH
238 svn switch -q $BRANCH
239 show_last_commit
240 svn copy -q Module/ProjectA Module/ProjectB
241 echo "Module/ProjectB/FileA1.txt (Test 13-1)" >> $WC/Module/ProjectB/FileA1.txt
242 echo "Module/ProjectB/FileA2.txt (Test 13-1)" >> $WC/Module/ProjectB/FileA2.txt
243 svn_commit "Test 13: Copy Module/ProjectA -> Module/ProjectB"
244 svn mv -q Module/ProjectB/FileA1.txt Module/ProjectB/FileB1.txt
245 echo "Module/ProjectB/FileB1.txt (Test 13-2)" >> $WC/Module/ProjectB/FileB1.txt
246 svn mv -q Module/ProjectB/FileA2.txt Module/ProjectB/FileB2.txt
247 echo "Module/ProjectB/FileB2.txt (Test 13-2)" >> $WC/Module/ProjectB/FileB2.txt
248 svn_commit "Test 13: Rename Module/ProjectB/FileA*.txt -> FileB*.txt"
249 svn copy -q Module/ProjectB/FileB2.txt Module/ProjectB/FileB3.txt
250 echo "Module/ProjectB/FileB3.txt (Test 13-3)" >> $WC/Module/ProjectB/FileB3.txt
251 svn rm -q Module/ProjectB/FileB1.txt
252 echo "Module/ProjectB/FileB1.txt (Test 13-3 - Replaced)" >> $WC/Module/ProjectB/FileB1.txt
253 svn add -q Module/ProjectB/FileB1.txt
254 svn_commit "Test 13: Edits to Module/ProjectB/FileB*.txt"
255 svn switch -q $TRUNK
256 svn merge -q $BRANCH
257 svn_commit "Test 13: Create Module/ProjectB from Module/ProjectA"
258
259 # Test #14: Verify renames
260 BRANCH="$REPOURL/branches/test14"
261 svn copy -q -m "Create branch" $TRUNK $BRANCH
262 svn switch -q $BRANCH
263 show_last_commit
264 echo "Module/ProjectB/FileB1.txt (Test 14)" >> $WC/Module/ProjectB/FileB1.txt
265 echo "Module/ProjectB/FileB2.txt (Test 14)" >> $WC/Module/ProjectB/FileB2.txt
266 echo "Module/ProjectB/FileB3.txt (Test 14)" >> $WC/Module/ProjectB/FileB3.txt
267 svn_commit "Test 14: Verify Module/ProjectB/FileB*.txt"
268 svn switch -q $TRUNK
269 svn merge -q $BRANCH
270 svn_commit "Test 14: Verify Module/ProjectB/FileB*.txt"
271
272 # Test #15: Replace copy-from
273 BRANCH="$REPOURL/branches/test15"
274 svn copy -q -m "Create branch" $TRUNK $BRANCH
275 svn switch -q $BRANCH
276 show_last_commit
277 svn rm -q Module/ProjectB/FileB2.txt
278 svn copy -q -r 22 $TRUNK/Module/ProjectC/FileC1.txt@22 Module/ProjectB/FileB2.txt
279 echo "Module/ProjectB/FileB2.txt (Test 15 - Replaced)" >> $WC/Module/ProjectB/FileB2.txt
280 svn_commit "Test 15: Replace Module/ProjectB/FileB2.txt from earlier Module/ProjectC/FileC1.txt"
281 svn switch -q $TRUNK
282 svn merge -q $BRANCH
283 svn_commit "Test 15: Replace Module/ProjectB/FileB2.txt from earlier Module/ProjectC/FileC1.txt"
284
285 # Test #16: Verify replace
286 BRANCH="$REPOURL/branches/test16"
287 svn copy -q -m "Create branch" $TRUNK $BRANCH
288 svn switch -q $BRANCH
289 show_last_commit
290 echo "Module/ProjectB/FileB2.txt (Test 16)" >> $WC/Module/ProjectB/FileB2.txt
291 svn_commit "Test 16: Verify Module/ProjectB/FileB2.txt"
292 svn switch -q $TRUNK
293 svn merge -q $BRANCH
294 svn_commit "Test 16: Verify Module/ProjectB/FileB2.txt"
295
296 # Test #17: Copy-from replaces and add's inside top-level initial-add folder
297 BRANCH="$REPOURL/branches/test17"
298 svn copy -q -m "Create branch" $TRUNK $BRANCH
299 svn switch -q $BRANCH
300 show_last_commit
301 svn mkdir -q Module2
302 svn copy -q Module/ProjectB Module2/ProjectB
303 echo "Module2/ProjectB/FileB1.txt (Test 17-1)" >> $WC/Module2/ProjectB/FileB1.txt
304 echo "Module2/ProjectB/FileB2.txt (Test 17-1)" >> $WC/Module2/ProjectB/FileB2.txt
305 echo "Module2/ProjectB/FileB3.txt (Test 17-1)" >> $WC/Module2/ProjectB/FileB3.txt
306 svn_commit "Test 17: Copy Module/ProjectB -> Module2/ProjectB"
307 svn rm -q Module2/ProjectB/FileB1.txt
308 svn copy -q -r 22 $TRUNK/Module/ProjectC/FileC2.txt@22 Module2/ProjectB/FileB1.txt
309 echo "Module2/ProjectB/FileB1.txt (Test 17-2)" >> $WC/Module2/ProjectB/FileB1.txt
310 svn_commit "Test 17: Replace Module2/ProjectB/FileB1.txt from earlier Module/ProjectC/FileC2.txt"
311 svn switch -q $TRUNK
312 svn merge -q $BRANCH
313 svn_commit "Test 17: Create Module2/ProjectB from Module/ProjectB"
314
315 # Clean-up
316 echo "Cleaning-up..."
317 rm -rf $WC