Debian Codegraph @

tests/test-convert-svn-source.t

raw
1 #require svn svn-bindings
2
3 $ filter_svn_output () {
4 > grep -E -v 'Committing|Updating|(^$)' | sed -e 's/done$//' || true
5 > }
6
7 $ cat >> $HGRCPATH <<EOF
8 > [extensions]
9 > convert =
10 > [convert]
11 > svn.trunk = mytrunk
12 > EOF
13
14 $ svnadmin create svn-repo
15 $ SVNREPOPATH=`pwd`/svn-repo
16 $ SVNREPOURL="`"$PYTHON" $TESTDIR/svnurlof.py \"$SVNREPOPATH\"`"
17 $ INVALIDREVISIONID=svn:x2147622-4a9f-4db4-a8d3-13562ff547b2/proj%20B/mytrunk@1
18 $ VALIDREVISIONID=svn:a2147622-4a9f-4db4-a8d3-13562ff547b2/proj%20B/mytrunk/mytrunk@1
19
20 Now test that it works with trunk/tags layout, but no branches yet.
21
22 Initial svn import
23
24 $ mkdir projB
25 $ cd projB
26 $ mkdir mytrunk
27 $ mkdir tags
28 $ cd ..
29
30 $ svn import -m "init projB" projB "$SVNREPOURL/proj%20B" | filter_svn_output | sort
31 Adding projB/mytrunk
32 Adding projB/tags
33 Committed revision 1.
34
35 Update svn repository
36
37 $ svn co "$SVNREPOURL/proj%20B/mytrunk" B | filter_svn_output
38 Checked out revision 1.
39 $ cd B
40 $ echo hello > 'letter .txt'
41 $ svn add 'letter .txt' | filter_svn_output
42 A letter .txt
43 $ svn ci -m hello | filter_svn_output
44 Adding letter .txt
45 Transmitting file data .
46 Committed revision 2.
47
48 $ svn-safe-append.py world 'letter .txt'
49 $ svn ci -m world | filter_svn_output
50 Sending letter .txt
51 Transmitting file data .
52 Committed revision 3.
53
54 $ svn copy -m "tag v0.1" "$SVNREPOURL/proj%20B/mytrunk" "$SVNREPOURL/proj%20B/tags/v0.1" | filter_svn_output
55 Committed revision 4.
56
57 $ svn-safe-append.py 'nice day today!' 'letter .txt'
58 $ svn ci -m "nice day" | filter_svn_output
59 Sending letter .txt
60 Transmitting file data .
61 Committed revision 5.
62 $ cd ..
63
64 Convert to hg once and also test localtimezone option
65
66 NOTE: This doesn't check all time zones -- it merely determines that
67 the configuration option is taking effect.
68
69 An arbitrary (U.S.) time zone is used here. TZ=US/Hawaii is selected
70 since it does not use DST (unlike other U.S. time zones) and is always
71 a fixed difference from UTC.
72
73 $ TZ=US/Hawaii hg convert --config convert.localtimezone=True "$SVNREPOURL/proj%20B" B-hg
74 initializing destination B-hg repository
75 scanning source...
76 sorting...
77 converting...
78 3 init projB
79 2 hello
80 1 world
81 0 nice day
82 updating tags
83
84 Update svn repository again
85
86 $ cd B
87 $ svn-safe-append.py "see second letter" 'letter .txt'
88 $ echo "nice to meet you" > letter2.txt
89 $ svn add letter2.txt | filter_svn_output
90 A letter2.txt
91 $ svn ci -m "second letter" | filter_svn_output
92 Sending letter .txt
93 Adding letter2.txt
94 Transmitting file data ..
95 Committed revision 6.
96
97 $ svn copy -m "tag v0.2" "$SVNREPOURL/proj%20B/mytrunk" "$SVNREPOURL/proj%20B/tags/v0.2" | filter_svn_output
98 Committed revision 7.
99
100 $ svn-safe-append.py "blah-blah-blah" letter2.txt
101 $ svn ci -m "work in progress" | filter_svn_output
102 Sending letter2.txt
103 Transmitting file data .
104 Committed revision 8.
105 $ cd ..
106
107 $ hg convert -s svn "$SVNREPOURL/proj%20B/non-existent-path" dest
108 initializing destination dest repository
109 abort: no revision found in module /proj B/non-existent-path
110 [255]
111
112 ########################################
113
114 Test incremental conversion
115
116 $ TZ=US/Hawaii hg convert --config convert.localtimezone=True "$SVNREPOURL/proj%20B" B-hg
117 scanning source...
118 sorting...
119 converting...
120 1 second letter
121 0 work in progress
122 updating tags
123
124 $ cd B-hg
125 $ hg log -G --template '{rev} {desc|firstline} date: {date|date} files: {files}\n'
126 o 7 update tags date: * +0000 files: .hgtags (glob)
127 |
128 o 6 work in progress date: * -1000 files: letter2.txt (glob)
129 |
130 o 5 second letter date: * -1000 files: letter .txt letter2.txt (glob)
131 |
132 o 4 update tags date: * +0000 files: .hgtags (glob)
133 |
134 o 3 nice day date: * -1000 files: letter .txt (glob)
135 |
136 o 2 world date: * -1000 files: letter .txt (glob)
137 |
138 o 1 hello date: * -1000 files: letter .txt (glob)
139 |
140 o 0 init projB date: * -1000 files: (glob)
141
142 $ hg tags -q
143 tip
144 v0.2
145 v0.1
146 $ cd ..
147
148 Test filemap
149 $ echo 'include letter2.txt' > filemap
150 $ hg convert --filemap filemap "$SVNREPOURL/proj%20B/mytrunk" fmap
151 initializing destination fmap repository
152 scanning source...
153 sorting...
154 converting...
155 5 init projB
156 4 hello
157 3 world
158 2 nice day
159 1 second letter
160 0 work in progress
161 $ hg -R fmap branch -q
162 default
163 $ hg log -G -R fmap --template '{rev} {desc|firstline} files: {files}\n'
164 o 1 work in progress files: letter2.txt
165 |
166 o 0 second letter files: letter2.txt
167
168 Convert with --full adds and removes files that didn't change
169
170 $ cd B
171 $ echo >> "letter .txt"
172 $ svn ci -m 'nothing' | filter_svn_output
173 Sending letter .txt
174 Transmitting file data .
175 Committed revision 9.
176 $ cd ..
177
178 $ echo 'rename letter2.txt letter3.txt' > filemap
179 $ hg convert --filemap filemap --full "$SVNREPOURL/proj%20B/mytrunk" fmap
180 scanning source...
181 sorting...
182 converting...
183 0 nothing
184 $ hg -R fmap st --change tip
185 A letter .txt
186 A letter3.txt
187 R letter2.txt
188
189 test invalid splicemap1
190
191 $ cat > splicemap <<EOF
192 > $INVALIDREVISIONID $VALIDREVISIONID
193 > EOF
194 $ hg convert --splicemap splicemap "$SVNREPOURL/proj%20B/mytrunk" smap
195 initializing destination smap repository
196 abort: splicemap entry svn:x2147622-4a9f-4db4-a8d3-13562ff547b2/proj%20B/mytrunk@1 is not a valid revision identifier
197 [255]
198
199 Test stop revision
200 $ hg convert --rev 1 "$SVNREPOURL/proj%20B/mytrunk" stoprev
201 initializing destination stoprev repository
202 scanning source...
203 sorting...
204 converting...
205 0 init projB
206 $ hg -R stoprev branch -q
207 default
208
209 Check convert_revision extra-records.
210 This is also the only place testing more than one extra field in a revision.
211
212 $ cd stoprev
213 $ hg tip --debug | grep extra
214 extra: branch=default
215 extra: convert_revision=svn:........-....-....-....-............/proj B/mytrunk@1 (re)
216 $ cd ..
217
218 Test converting empty heads (issue3347).
219 Also tests getting logs directly without debugsvnlog.
220
221 $ svnadmin create svn-empty
222 $ svnadmin load -q svn-empty < "$TESTDIR/svn/empty.svndump"
223 $ hg --config convert.svn.trunk= --config convert.svn.debugsvnlog=0 convert svn-empty
224 assuming destination svn-empty-hg
225 initializing destination svn-empty-hg repository
226 scanning source...
227 sorting...
228 converting...
229 1 init projA
230 0 adddir
231 $ hg --config convert.svn.trunk= convert "$SVNREPOURL/../svn-empty/trunk"
232 assuming destination trunk-hg
233 initializing destination trunk-hg repository
234 scanning source...
235 sorting...
236 converting...
237 1 init projA
238 0 adddir
239
240 Test that a too-new repository format is properly rejected:
241 $ mv svn-empty/format format
242 $ echo 999 > svn-empty/format
243 It's important that this command explicitly specify svn, otherwise it
244 can have surprising side effects (like falling back to a perforce
245 depot that can be seen from the test environment and slurping from that.)
246 $ hg convert --source-type svn svn-empty this-will-fail
247 initializing destination this-will-fail repository
248 file:/*/$TESTTMP/svn-empty does not look like a Subversion repository to libsvn version 1.*.* (glob)
249 abort: svn-empty: missing or unsupported repository
250 [255]
251 $ mv format svn-empty/format
252
253 enable svn subrepos
254
255 $ cat >> $HGRCPATH <<EOF
256 > [subrepos]
257 > svn:allowed = true
258 > EOF
259
260 try converting when we have an svn subrepo and a merge in hg superrepo (issue5657)
261
262 $ cd "$TESTTMP"
263 $ hg init withmerge
264 $ cd withmerge
265 $ echo "subrepo = [svn]$SVNREPOURL" >.hgsub
266 $ hg add .hgsub
267 $ svn checkout "$SVNREPOURL" subrepo | sort
268 A subrepo/proj B
269 A subrepo/proj B/mytrunk
270 A subrepo/proj B/mytrunk/letter .txt
271 A subrepo/proj B/mytrunk/letter2.txt
272 A subrepo/proj B/tags
273 A subrepo/proj B/tags/v0.1
274 A subrepo/proj B/tags/v0.1/letter .txt
275 A subrepo/proj B/tags/v0.2
276 A subrepo/proj B/tags/v0.2/letter .txt
277 A subrepo/proj B/tags/v0.2/letter2.txt
278 Checked out revision 9.
279 $ hg ci -m "Adding svn subrepo"
280 $ touch file1.txt
281 $ hg add file1.txt
282 $ hg ci -m "Adding file1"
283 $ hg up 0
284 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
285 $ touch file2.txt
286 $ hg add file2.txt
287 $ hg ci -m "Adding file2"
288 created new head
289 $ hg merge 1
290 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
291 (branch merge, don't forget to commit)
292 $ hg ci -m "merged"
293 $ cd ..
294 $ hg --config extensions.convert= convert withmerge withmerge-converted
295 initializing destination withmerge-converted repository
296 scanning source...
297 sorting...
298 converting...
299 3 Adding svn subrepo
300 2 Adding file1
301 1 Adding file2
302 0 merged
303 $ cd withmerge-converted
304 $ hg up | sort
305 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
306 A subrepo/proj B
307 A subrepo/proj B/mytrunk
308 A subrepo/proj B/mytrunk/letter .txt
309 A subrepo/proj B/mytrunk/letter2.txt
310 A subrepo/proj B/tags
311 A subrepo/proj B/tags/v0.1
312 A subrepo/proj B/tags/v0.1/letter .txt
313 A subrepo/proj B/tags/v0.2
314 A subrepo/proj B/tags/v0.2/letter .txt
315 A subrepo/proj B/tags/v0.2/letter2.txt
316 Checked out revision 9.
317 $ ls
318 file1.txt
319 file2.txt
320 subrepo