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