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