]> Tony Duckles's Git Repositories (git.nynim.org) - svn2svn.git/blob - tests/make-ref-repo.sh
Handle empty "svn log" commit messages
[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_commit "Initial population"
47
48 # Test #1: Add new file
49 # * Test simple copy-from branch
50 BRANCH="$REPOURL/branches/test1"
51 svn copy -q -m "Create branch" $TRUNK $BRANCH
52 svn switch -q $BRANCH
53 show_last_commit
54 mkdir -p $WC/Module/ProjectB
55 echo "Module/ProjectB/FileB1.txt (Test 1)" >> $WC/Module/ProjectB/FileB1.txt
56 svn add -q $WC/Module/ProjectB
57 svn_commit "Test 1: Add Module/ProjectB"
58 svn switch -q $TRUNK
59 svn merge -q $BRANCH
60 svn ci -q --with-revprop 'testprop=Test 1 message' -m "Test 1: Add Module/ProjectB"
61 svn up -q
62 show_last_commit
63
64 # Empty commit message
65 echo "Module/ProjectB/FileB1.txt (Test 1.1)" >> $WC/Module/ProjectB/FileB1.txt
66 svn_commit ""
67
68 # Test #2: Rename files
69 # * Test rename support
70 # * Test committing rename in two different branch commits: first deletion, then add
71 BRANCH="$REPOURL/branches/test2"
72 svn copy -q -m "Create branch" $TRUNK $BRANCH
73 svn switch -q $BRANCH
74 show_last_commit
75 svn mv -q Module/ProjectA/FileA2.txt Module/ProjectB/FileB2.txt
76 echo "Module/ProjectB/FileB2.txt (Test 2)" >> $WC/Module/ProjectB/FileB2.txt
77 svn_commit "Test 2: Rename Module/ProjectA/FileA2.txt -> Module/ProjectB/FileB2.txt (part 1 of 2)" Module/ProjectA
78 svn_commit "Test 2: Rename Module/ProjectA/FileA2.txt -> Module/ProjectB/FileB2.txt (part 2 of 2)" Module/ProjectB
79 svn switch -q $TRUNK
80 svn merge -q $BRANCH
81 svn_commit "Test 2: Rename Module/ProjectA/FileA2.txt -> Module/ProjectB/FileB3.txt"
82
83 # Test #3: Verify rename
84 BRANCH="$REPOURL/branches/test3"
85 svn copy -q -m "Create branch" $TRUNK $BRANCH
86 svn switch -q $BRANCH
87 show_last_commit
88 echo "Module/ProjectB/FileB2.txt (Test 3)" >> $WC/Module/ProjectB/FileB2.txt
89 svn_commit "Test 3: Verify Module/ProjectB/FileB2.txt"
90 svn switch -q $TRUNK
91 svn merge -q $BRANCH
92 svn_commit "Test 3: Verify Module/ProjectB/FileB2.txt"
93
94 # Test #4: Replace files
95 # * Test replace support
96 BRANCH="$REPOURL/branches/test4"
97 svn copy -q -m "Create branch" $TRUNK $BRANCH
98 svn switch -q $BRANCH
99 show_last_commit
100 svn rm -q Module/ProjectA/FileA1.txt
101 echo "Module/ProjectA/FileA1.txt (Test 4 - Replaced)" >> $WC/Module/ProjectA/FileA1.txt
102 svn add -q Module/ProjectA/FileA1.txt
103 svn_commit "Test 4: Replace Module/ProjectA/FileA1.txt"
104 svn switch -q $TRUNK
105 svn merge -q $BRANCH
106 svn_commit "Test 4: Replace Module/ProjectA/FileA1.txt"
107
108 # Test #5: Rename files + folders
109 # * Test rename support
110 # * Create complex find-ancestors case, where files are renamed within a renamed folder on a branch
111 BRANCH="$REPOURL/branches/test5"
112 svn copy -q -m "Create branch" $TRUNK $BRANCH
113 svn switch -q $BRANCH
114 show_last_commit
115 svn mv -q Module/ProjectB Module/ProjectC
116 svn mv -q Module/ProjectC/FileB1.txt Module/ProjectC/FileC1.txt
117 echo "Module/ProjectC/FileC1.txt (Test 5)" >> $WC/Module/ProjectC/FileC1.txt
118 svn mv -q Module/ProjectC/FileB2.txt Module/ProjectC/FileC2.txt
119 echo "Module/ProjectC/FileC2.txt (Test 5)" >> $WC/Module/ProjectC/FileC2.txt
120 svn_commit "Test 5: Rename Module/ProjectB -> Module/ProjectC"
121 svn switch -q $TRUNK
122 svn merge -q $BRANCH
123 svn_commit "Test 5: Rename Module/ProjectB -> Module/ProjectC"
124
125 # Test #6: Verify rename
126 BRANCH="$REPOURL/branches/test6"
127 svn copy -q -m "Create branch" $TRUNK $BRANCH
128 svn switch -q $BRANCH
129 show_last_commit
130 echo "Module/ProjectC/FileC1.txt (Test 6)" >> $WC/Module/ProjectC/FileC1.txt
131 echo "Module/ProjectC/FileC2.txt (Test 6)" >> $WC/Module/ProjectC/FileC2.txt
132 svn_commit "Test 6: Verify Module/ProjectC/FileC*.txt"
133 svn switch -q $TRUNK
134 svn merge -q $BRANCH
135 svn_commit "Test 6: Verify Module/ProjectC/FileC*.txt"
136
137 # Test #7: Rename files
138 # * Test rename support
139 # * Rename multiple files in the same folder
140 BRANCH="$REPOURL/branches/test7"
141 svn copy -q -m "Create branch" $TRUNK $BRANCH
142 svn switch -q $BRANCH
143 show_last_commit
144 svn mv -q Module/ProjectC/FileC1.txt Module/ProjectC/FileC3.txt
145 echo "Module/ProjectC/FileC3.txt (Test 7)" >> $WC/Module/ProjectC/FileC3.txt
146 svn mv -q Module/ProjectC/FileC2.txt Module/ProjectC/FileC4.txt
147 echo "Module/ProjectC/FileC4.txt (Test 7)" >> $WC/Module/ProjectC/FileC4.txt
148 svn_commit "Test 7: Rename Module/ProjectC/FileC*.txt"
149 svn switch -q $TRUNK
150 svn merge -q $BRANCH
151 svn_commit "Test 7: Rename Module/ProjectC/FileC*.txt"
152
153 # Test #8: Verify rename
154 BRANCH="$REPOURL/branches/test8"
155 svn copy -q -m "Create branch" $TRUNK $BRANCH
156 svn switch -q $BRANCH
157 show_last_commit
158 echo "Module/ProjectC/FileC3.txt (Test 8)" >> $WC/Module/ProjectC/FileC3.txt
159 echo "Module/ProjectC/FileC4.txt (Test 8)" >> $WC/Module/ProjectC/FileC4.txt
160 svn_commit "Test 8: Verify Module/ProjectC/FileC*.txt"
161 svn switch -q $TRUNK
162 svn merge -q $BRANCH
163 svn_commit "Test 8: Verify Module/ProjectC/FileC*.txt"
164
165 # Test #9: Copy from older revision
166 svn copy -q -r 8 $TRUNK/Module/ProjectA/FileA2.txt@8 $WC/Module/ProjectA/FileA2.txt
167 svn propdel -q svn:mergeinfo Module/ProjectA/FileA2.txt
168 svn_commit "Test 9: Restore Module/ProjectA/FileA2.txt"
169
170 # Test #10: Verify copy
171 BRANCH="$REPOURL/branches/test10"
172 svn copy -q -m "Create branch" $TRUNK $BRANCH
173 svn switch -q $BRANCH
174 show_last_commit
175 echo "Module/ProjectA/FileA2.txt (Test 10)" >> $WC/Module/ProjectA/FileA2.txt
176 svn_commit "Test 10: Verify Module/ProjectA/FileA2.txt"
177 svn switch -q $TRUNK
178 svn merge -q $BRANCH
179 svn_commit "Test 10: Verify Module/ProjectA/FileA2.txt"
180
181 # Test #11: Rename files + folders, multiple chained renames
182 # * Test rename support
183 # * Create complicated find-ancestors case, where files/folders are renamed multiple times on branch
184 BRANCH="$REPOURL/branches/test11"
185 svn copy -q -m "Create branch" $TRUNK $BRANCH
186 svn switch -q $BRANCH
187 show_last_commit
188 svn mv -q Module/ProjectC Module/ProjectD
189 svn mv -q Module/ProjectD/FileC3.txt Module/ProjectD/FileD1.txt
190 echo "Module/ProjectD/FileD1.txt (Test 11)" >> $WC/Module/ProjectD/FileD1.txt
191 svn mv -q Module/ProjectD/FileC4.txt Module/ProjectD/FileD2.txt
192 echo "Module/ProjectD/FileD2.txt (Test 11)" >> $WC/Module/ProjectD/FileD2.txt
193 svn_commit "Test 11: Rename Module/ProjectC -> Module/ProjectD (part 1 of 2)" Module/ProjectC Module/ProjectD/FileC3.txt Module/ProjectD/FileC4.txt
194 svn_commit "Test 11: Rename Module/ProjectC -> Module/ProjectD (part 2 of 2)"
195 BRANCH="$REPOURL/branches/test11-1"
196 svn copy -q -m "Create branch" $TRUNK $BRANCH
197 svn switch -q $BRANCH
198 show_last_commit
199 svn merge -q $REPOURL/branches/test11
200 svn_commit "Test 11: Re-branch"
201 svn mv -q Module/ProjectD Module/ProjectE
202 svn mv -q Module/ProjectE/FileD1.txt Module/ProjectE/FileE1.txt
203 echo "Module/ProjectE/FileE1.txt (Test 11-1)" >> $WC/Module/ProjectE/FileE1.txt
204 svn mv -q Module/ProjectE/FileD2.txt Module/ProjectE/FileE2.txt
205 echo "Module/ProjectE/FileE2.txt (Test 11-1)" >> $WC/Module/ProjectE/FileE2.txt
206 svn_commit "Test 11: Rename Module/ProjectD -> Module/ProjectE (part 1 of 2)" Module/ProjectD Module/ProjectE/FileD1.txt Module/ProjectE/FileD2.txt
207 svn_commit "Test 11: Rename Module/ProjectD -> Module/ProjectE (part 2 of 2)"
208 svn switch -q $TRUNK
209 svn merge -q $BRANCH
210 svn_commit "Test 11: Rename Module/ProjectC -> Module/ProjectE"
211
212 # Test #12: Verify renames
213 BRANCH="$REPOURL/branches/test12"
214 svn copy -q -m "Create branch" $TRUNK $BRANCH
215 svn switch -q $BRANCH
216 show_last_commit
217 echo "Module/ProjectE/FileE1.txt (Test 12)" >> $WC/Module/ProjectE/FileE1.txt
218 echo "Module/ProjectE/FileE2.txt (Test 12)" >> $WC/Module/ProjectE/FileE2.txt
219 svn_commit "Test 12: Verify Module/ProjectE/FileE*.txt"
220 svn switch -q $TRUNK
221 svn merge -q $BRANCH
222 svn_commit "Test 12: Verify Module/ProjectE/FileE*.txt"
223
224 # Test #13: Replaces and add's inside a parent renamed folder.
225 BRANCH="$REPOURL/branches/test13"
226 svn copy -q -m "Create branch" $TRUNK $BRANCH
227 svn switch -q $BRANCH
228 show_last_commit
229 svn copy -q Module/ProjectA Module/ProjectB
230 echo "Module/ProjectB/FileA1.txt (Test 13-1)" >> $WC/Module/ProjectB/FileA1.txt
231 echo "Module/ProjectB/FileA2.txt (Test 13-1)" >> $WC/Module/ProjectB/FileA2.txt
232 svn_commit "Test 13: Copy Module/ProjectA -> Module/ProjectB"
233 svn mv -q Module/ProjectB/FileA1.txt Module/ProjectB/FileB1.txt
234 echo "Module/ProjectB/FileB1.txt (Test 13-2)" >> $WC/Module/ProjectB/FileB1.txt
235 svn mv -q Module/ProjectB/FileA2.txt Module/ProjectB/FileB2.txt
236 echo "Module/ProjectB/FileB2.txt (Test 13-2)" >> $WC/Module/ProjectB/FileB2.txt
237 svn_commit "Test 13: Rename Module/ProjectB/FileA*.txt -> FileB*.txt"
238 svn copy -q Module/ProjectB/FileB2.txt Module/ProjectB/FileB3.txt
239 echo "Module/ProjectB/FileB3.txt (Test 13-3)" >> $WC/Module/ProjectB/FileB3.txt
240 svn rm -q Module/ProjectB/FileB1.txt
241 echo "Module/ProjectB/FileB1.txt (Test 13-3 - Replaced)" >> $WC/Module/ProjectB/FileB1.txt
242 svn add -q Module/ProjectB/FileB1.txt
243 svn_commit "Test 13: Edits to Module/ProjectB/FileB*.txt"
244 svn switch -q $TRUNK
245 svn merge -q $BRANCH
246 svn_commit "Test 13: Create Module/ProjectB from Module/ProjectA"
247
248 # Test #14: Verify renames
249 BRANCH="$REPOURL/branches/test14"
250 svn copy -q -m "Create branch" $TRUNK $BRANCH
251 svn switch -q $BRANCH
252 show_last_commit
253 echo "Module/ProjectB/FileB1.txt (Test 14)" >> $WC/Module/ProjectB/FileB1.txt
254 echo "Module/ProjectB/FileB2.txt (Test 14)" >> $WC/Module/ProjectB/FileB2.txt
255 echo "Module/ProjectB/FileB3.txt (Test 14)" >> $WC/Module/ProjectB/FileB3.txt
256 svn_commit "Test 14: Verify Module/ProjectB/FileB*.txt"
257 svn switch -q $TRUNK
258 svn merge -q $BRANCH
259 svn_commit "Test 14: Verify Module/ProjectB/FileB*.txt"
260
261 # Test #15: Replace copy-from
262 BRANCH="$REPOURL/branches/test15"
263 svn copy -q -m "Create branch" $TRUNK $BRANCH
264 svn switch -q $BRANCH
265 show_last_commit
266 svn rm -q Module/ProjectB/FileB2.txt
267 svn copy -q -r 22 $TRUNK/Module/ProjectC/FileC1.txt@22 Module/ProjectB/FileB2.txt
268 echo "Module/ProjectB/FileB2.txt (Test 15 - Replaced)" >> $WC/Module/ProjectB/FileB2.txt
269 svn_commit "Test 15: Replace Module/ProjectB/FileB2.txt from earlier Module/ProjectC/FileC1.txt"
270 svn switch -q $TRUNK
271 svn merge -q $BRANCH
272 svn_commit "Test 15: Replace Module/ProjectB/FileB2.txt from earlier Module/ProjectC/FileC1.txt"
273
274 # Test #16: Verify replace
275 BRANCH="$REPOURL/branches/test16"
276 svn copy -q -m "Create branch" $TRUNK $BRANCH
277 svn switch -q $BRANCH
278 show_last_commit
279 echo "Module/ProjectB/FileB2.txt (Test 16)" >> $WC/Module/ProjectB/FileB2.txt
280 svn_commit "Test 16: Verify Module/ProjectB/FileB2.txt"
281 svn switch -q $TRUNK
282 svn merge -q $BRANCH
283 svn_commit "Test 16: Verify Module/ProjectB/FileB2.txt"
284
285 # Test #17: Copy-from replaces and add's inside top-level initial-add folder
286 BRANCH="$REPOURL/branches/test17"
287 svn copy -q -m "Create branch" $TRUNK $BRANCH
288 svn switch -q $BRANCH
289 show_last_commit
290 svn mkdir -q Module2
291 svn copy -q Module/ProjectB Module2/ProjectB
292 echo "Module2/ProjectB/FileB1.txt (Test 17-1)" >> $WC/Module2/ProjectB/FileB1.txt
293 echo "Module2/ProjectB/FileB2.txt (Test 17-1)" >> $WC/Module2/ProjectB/FileB2.txt
294 echo "Module2/ProjectB/FileB3.txt (Test 17-1)" >> $WC/Module2/ProjectB/FileB3.txt
295 svn_commit "Test 17: Copy Module/ProjectB -> Module2/ProjectB"
296 svn rm -q Module2/ProjectB/FileB1.txt
297 svn copy -q -r 22 $TRUNK/Module/ProjectC/FileC2.txt@22 Module2/ProjectB/FileB1.txt
298 echo "Module2/ProjectB/FileB1.txt (Test 17-2)" >> $WC/Module2/ProjectB/FileB1.txt
299 svn_commit "Test 17: Replace Module2/ProjectB/FileB1.txt from earlier Module/ProjectC/FileC2.txt"
300 svn switch -q $TRUNK
301 svn merge -q $BRANCH
302 svn_commit "Test 17: Create Module2/ProjectB from Module/ProjectB"
303
304 # Clean-up
305 echo "Cleaning-up..."
306 rm -rf $WC