]> Tony Duckles's Git Repositories (git.nynim.org) - svn2svn.git/blob - tests/make-ref-repo.sh
Major rewrite for replay_svn_ancestors() -> replay_svn_copyfrom()
[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%-20s%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 complicated find-ancestors case, where files/folders are renamed multiple times on 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 4: Rename Module/ProjectB -> Module/ProjectC"
115 svn switch -q $TRUNK
116 svn merge -q $BRANCH
117 svn_commit "Test 4: 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"
188 svn mv -q Module/ProjectD Module/ProjectE
189 svn mv -q Module/ProjectE/FileD1.txt Module/ProjectE/FileE1.txt
190 echo "Module/ProjectE/FileE1.txt (Test 11-1)" >> $WC/Module/ProjectE/FileE1.txt
191 svn mv -q Module/ProjectE/FileD2.txt Module/ProjectE/FileE2.txt
192 echo "Module/ProjectE/FileE2.txt (Test 11-1)" >> $WC/Module/ProjectE/FileE2.txt
193 svn_commit "Test 11: Rename Module/ProjectD -> Module/ProjectE"
194 svn switch -q $TRUNK
195 svn merge -q $BRANCH
196 svn_commit "Test 11: Rename Module/ProjectC -> Module/ProjectE"
197
198 # Clean-up
199 echo "Cleaning-up..."
200 rm -rf $WC