]> Tony Duckles's Git Repositories (git.nynim.org) - svn2svn.git/blob - tests/make-ref-repo.sh
Test scripts
[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%-18s%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 # Clean-up
30 echo "Cleaning-up..."
31 rm -rf $REPO $WC
32
33 # Init repo
34 echo "Creating _repo_ref..."
35 svnadmin create $REPO
36 svn mkdir -q -m "Add /trunk" $REPOURL/trunk
37 show_last_commit
38 svn mkdir -q -m "Add /branches" $REPOURL/branches
39 show_last_commit
40 TRUNK="$REPOURL/trunk"
41 svn co -q $TRUNK $WC
42 cd $WC
43
44 # Initial Population
45 mkdir -p $WC/Module/ProjectA
46 echo "Module/ProjectA/FileA1.txt" > $WC/Module/ProjectA/FileA1.txt
47 echo "Module/ProjectA/FileA2.txt" > $WC/Module/ProjectA/FileA2.txt
48 echo "Module/ProjectA/FileA3.txt" > $WC/Module/ProjectA/FileA3.txt
49 svn -q add $WC/Module
50 svn_commit "Initial population"
51
52 # Add new file
53 # * Test simple copy-from branch
54 BRANCH="$REPOURL/branches/fix1"
55 svn copy -q -m "Create branch" $TRUNK $BRANCH
56 svn switch -q $BRANCH
57 show_last_commit
58 mkdir -p $WC/Module/ProjectB
59 echo "Module/ProjectB/FileB1.txt" > $WC/Module/ProjectB/FileB1.txt
60 echo "Module/ProjectB/FileB2.txt" > $WC/Module/ProjectB/FileB2.txt
61 svn add -q $WC/Module/ProjectB
62 svn_commit "Fix 1: Add Module/ProjectB"
63 svn switch -q $TRUNK
64 svn merge -q $BRANCH
65 svn_commit "Fix 1: Add Module/ProjectB"
66
67 # Rename files
68 # * Test rename support
69 # * Test committing rename in two different branch commits: first deletion, then add
70 BRANCH="$REPOURL/branches/fix2"
71 svn copy -q -m "Create branch" $TRUNK $BRANCH
72 svn switch -q $BRANCH
73 show_last_commit
74 svn mv -q Module/ProjectA/FileA2.txt Module/ProjectB/FileB3.txt
75 svn_commit "Fix 2: Rename Module/ProjectA/FileA2.txt -> Module/ProjectB/FileB3.txt (part 1 of 2)" Module/ProjectA
76 svn_commit "Fix 2: Rename Module/ProjectA/FileA2.txt -> Module/ProjectB/FileB3.txt (part 2 of 2)" Module/ProjectB
77 svn switch -q $TRUNK
78 svn merge -q $BRANCH
79 svn_commit "Fix 2: Rename Module/ProjectA/FileA2.txt -> Module/ProjectB/FileB3.txt"
80
81 # Verify rename
82 BRANCH="$REPOURL/branches/fix3"
83 svn copy -q -m "Create branch" $TRUNK $BRANCH
84 svn switch -q $BRANCH
85 show_last_commit
86 echo "Module/ProjectB/FileB3.txt (from Fix 3)" >> $WC/Module/ProjectB/FileB3.txt
87 svn_commit "Fix 3: Modify Module/ProjectB/FileB3.txt"
88 svn switch -q $TRUNK
89 svn merge -q $BRANCH
90 svn_commit "Fix 3: Modify Module/ProjectB/FileB3.txt"
91
92 # Rename files + folders
93 # * Test rename support
94 # * Create complicated find-ancestors case, where files/folders are renamed multiple times on branch
95 BRANCH="$REPOURL/branches/fix4"
96 svn copy -q -m "Create branch" $TRUNK $BRANCH
97 svn switch -q $BRANCH
98 show_last_commit
99 svn mv -q Module/ProjectB Module/ProjectC
100 svn mv -q Module/ProjectC/FileB1.txt Module/ProjectC/FileC1.txt
101 echo "Module/ProjectC/FileC1.txt" >> $WC/Module/ProjectC/FileC1.txt
102 svn mv -q Module/ProjectC/FileB2.txt Module/ProjectC/FileC2.txt
103 echo "Module/ProjectC/FileC2.txt" >> $WC/Module/ProjectC/FileC2.txt
104 svn mv -q Module/ProjectC/FileB3.txt Module/ProjectC/FileC3.txt
105 echo "Module/ProjectC/FileC3.txt" >> $WC/Module/ProjectC/FileC3.txt
106 svn_commit "Fix 4: Rename Module/ProjectB -> Module/ProjectC"
107 svn switch -q $TRUNK
108 svn merge -q $BRANCH
109 svn_commit "Fix 4: Rename Module/ProjectB -> Module/ProjectC"
110
111 # Verify rename
112 BRANCH="$REPOURL/branches/fix5"
113 svn copy -q -m "Create branch" $TRUNK $BRANCH
114 svn switch -q $BRANCH
115 show_last_commit
116 echo "Module/ProjectC/FileC1.txt (from Fix 5)" >> $WC/Module/ProjectC/FileC1.txt
117 echo "Module/ProjectC/FileC2.txt (from Fix 5)" >> $WC/Module/ProjectC/FileC2.txt
118 echo "Module/ProjectC/FileC3.txt (from Fix 5)" >> $WC/Module/ProjectC/FileC3.txt
119 svn_commit "Fix 5: Modify Module/ProjectC/FileC*.txt"
120 svn switch -q $TRUNK
121 svn merge -q $BRANCH
122 svn_commit "Fix 5: Modify Module/ProjectC/FileC*.txt"
123
124 # Copy from older revision
125 svn copy -q -r 8 $TRUNK/Module/ProjectA/FileA2.txt@8 $WC/Module/ProjectA/FileA2.txt
126 svn_commit "Fix 6: Restore Module/ProjectA/FileA2.txt"
127
128 # Verify copy
129 BRANCH="$REPOURL/branches/fix7"
130 svn copy -q -m "Create branch" $TRUNK $BRANCH
131 svn switch -q $BRANCH
132 show_last_commit
133 echo "Module/ProjectA/FileA2.txt (from Fix 7)" >> $WC/Module/ProjectA/FileA2.txt
134 svn_commit "Fix 7: Modify Module/ProjectA/FileA2.txt"
135 svn switch -q $TRUNK
136 svn merge -q $BRANCH
137 svn_commit "Fix 7: Modify Module/ProjectA/FileA2.txt"
138