Debian Codegraph @

tests/test-convert-svn-sink.t

raw
1 #require svn13
2
3 $ svnupanddisplay()
4 > {
5 > (
6 > cd $1;
7 > svn up -q;
8 > svn st -v | sed 's/ */ /g' | sort
9 > limit=''
10 > if [ $2 -gt 0 ]; then
11 > limit="--limit=$2"
12 > fi
13 > svn log --xml -v $limit | "$PYTHON" "$TESTDIR/svnxml.py"
14 > )
15 > }
16
17 $ cat >> $HGRCPATH <<EOF
18 > [extensions]
19 > convert =
20 > EOF
21
22 $ hg init a
23
24 Add
25
26 $ echo a > a/a
27 $ mkdir -p a/d1/d2
28 $ echo b > a/d1/d2/b
29 $ hg --cwd a ci -d '0 0' -A -m 'add a file'
30 adding a
31 adding d1/d2/b
32
33 Modify
34
35 $ svn-safe-append.py a a/a
36 $ hg --cwd a ci -d '1 0' -m 'modify a file'
37 $ hg --cwd a tip -q
38 1:e0e2b8a9156b
39
40 $ hg convert -d svn a
41 assuming destination a-hg
42 initializing svn repository 'a-hg'
43 initializing svn working copy 'a-hg-wc'
44 scanning source...
45 sorting...
46 converting...
47 1 add a file
48 0 modify a file
49 $ svnupanddisplay a-hg-wc 2
50 2 1 test d1
51 2 1 test d1/d2
52 2 1 test d1/d2/b
53 2 2 test .
54 2 2 test a
55 revision: 2
56 author: test
57 date: * (glob)
58 msg: modify a file
59 M /a
60 revision: 1
61 author: test
62 date: * (glob)
63 msg: add a file
64 A /a
65 A /d1
66 A /d1/d2
67 A /d1/d2/b
68 $ ls a a-hg-wc
69 a:
70 a
71 d1
72
73 a-hg-wc:
74 a
75 d1
76 $ cmp a/a a-hg-wc/a
77
78 Rename
79
80 $ hg --cwd a mv a b
81 $ hg --cwd a ci -d '2 0' -m 'rename a file'
82 $ hg --cwd a tip -q
83 2:eb5169441d43
84
85 $ hg convert -d svn a
86 assuming destination a-hg
87 initializing svn working copy 'a-hg-wc'
88 scanning source...
89 sorting...
90 converting...
91 0 rename a file
92 $ svnupanddisplay a-hg-wc 1
93 3 1 test d1
94 3 1 test d1/d2
95 3 1 test d1/d2/b
96 3 3 test .
97 3 3 test b
98 revision: 3
99 author: test
100 date: * (glob)
101 msg: rename a file
102 D /a
103 A /b (from /a@2)
104 $ ls a a-hg-wc
105 a:
106 b
107 d1
108
109 a-hg-wc:
110 b
111 d1
112
113 Copy
114
115 $ hg --cwd a cp b c
116
117 $ hg --cwd a ci -d '3 0' -m 'copy a file'
118 $ hg --cwd a tip -q
119 3:60effef6ab48
120
121 $ hg convert -d svn a
122 assuming destination a-hg
123 initializing svn working copy 'a-hg-wc'
124 scanning source...
125 sorting...
126 converting...
127 0 copy a file
128 $ svnupanddisplay a-hg-wc 1
129 4 1 test d1
130 4 1 test d1/d2
131 4 1 test d1/d2/b
132 4 3 test b
133 4 4 test .
134 4 4 test c
135 revision: 4
136 author: test
137 date: * (glob)
138 msg: copy a file
139 A /c (from /b@3)
140 $ ls a a-hg-wc
141 a:
142 b
143 c
144 d1
145
146 a-hg-wc:
147 b
148 c
149 d1
150
151 $ hg --cwd a rm b
152
153 Remove
154
155 $ hg --cwd a ci -d '4 0' -m 'remove a file'
156 $ hg --cwd a tip -q
157 4:87bbe3013fb6
158
159 $ hg convert -d svn a
160 assuming destination a-hg
161 initializing svn working copy 'a-hg-wc'
162 scanning source...
163 sorting...
164 converting...
165 0 remove a file
166 $ svnupanddisplay a-hg-wc 1
167 5 1 test d1
168 5 1 test d1/d2
169 5 1 test d1/d2/b
170 5 4 test c
171 5 5 test .
172 revision: 5
173 author: test
174 date: * (glob)
175 msg: remove a file
176 D /b
177 $ ls a a-hg-wc
178 a:
179 c
180 d1
181
182 a-hg-wc:
183 c
184 d1
185
186 Executable
187
188 #if execbit
189 $ chmod +x a/c
190 #else
191 $ echo fake >> a/c
192 #endif
193 $ hg --cwd a ci -d '5 0' -m 'make a file executable'
194 #if execbit
195 $ hg --cwd a tip -q
196 5:ff42e473c340
197 #else
198 $ hg --cwd a tip -q
199 5:817a700c8cf1
200 #endif
201
202 $ hg convert -d svn a
203 assuming destination a-hg
204 initializing svn working copy 'a-hg-wc'
205 scanning source...
206 sorting...
207 converting...
208 0 make a file executable
209 $ svnupanddisplay a-hg-wc 1
210 6 1 test d1
211 6 1 test d1/d2
212 6 1 test d1/d2/b
213 6 6 test .
214 6 6 test c
215 revision: 6
216 author: test
217 date: * (glob)
218 msg: make a file executable
219 M /c
220 #if execbit
221 $ test -x a-hg-wc/c
222 #endif
223
224 #if symlink
225
226 Symlinks
227
228 $ ln -s a/missing a/link
229 $ hg --cwd a commit -Am 'add symlink'
230 adding link
231 $ hg --cwd a mv link newlink
232 $ hg --cwd a commit -m 'move symlink'
233 $ hg convert -d svn a a-svnlink
234 initializing svn repository 'a-svnlink'
235 initializing svn working copy 'a-svnlink-wc'
236 scanning source...
237 sorting...
238 converting...
239 7 add a file
240 6 modify a file
241 5 rename a file
242 4 copy a file
243 3 remove a file
244 2 make a file executable
245 1 add symlink
246 0 move symlink
247 $ svnupanddisplay a-svnlink-wc 1
248 8 1 test d1
249 8 1 test d1/d2
250 8 1 test d1/d2/b
251 8 6 test c
252 8 8 test .
253 8 8 test newlink
254 revision: 8
255 author: test
256 date: * (glob)
257 msg: move symlink
258 D /link
259 A /newlink (from /link@7)
260
261 Make sure our changes don't affect the rest of the test cases
262
263 $ hg --cwd a up 5
264 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
265 $ hg --cwd a --config extensions.strip= strip -r 6
266 saved backup bundle to $TESTTMP/a/.hg/strip-backup/bd4f7b7a7067-ed505e42-backup.hg
267
268 #endif
269
270 Convert with --full adds and removes files that didn't change
271
272 $ touch a/f
273 $ hg -R a ci -Aqmf
274 $ echo "rename c d" > filemap
275 $ hg convert -d svn a --filemap filemap --full
276 assuming destination a-hg
277 initializing svn working copy 'a-hg-wc'
278 scanning source...
279 sorting...
280 converting...
281 0 f
282 $ svnupanddisplay a-hg-wc 1
283 7 7 test .
284 7 7 test d
285 7 7 test f
286 revision: 7
287 author: test
288 date: * (glob)
289 msg: f
290 D /c
291 A /d
292 D /d1
293 A /f
294
295 $ rm -rf a a-hg a-hg-wc
296
297
298 Executable in new directory
299
300 $ hg init a
301
302 $ mkdir a/d1
303 $ echo a > a/d1/a
304 #if execbit
305 $ chmod +x a/d1/a
306 #else
307 $ echo fake >> a/d1/a
308 #endif
309 $ hg --cwd a ci -d '0 0' -A -m 'add executable file in new directory'
310 adding d1/a
311
312 $ hg convert -d svn a
313 assuming destination a-hg
314 initializing svn repository 'a-hg'
315 initializing svn working copy 'a-hg-wc'
316 scanning source...
317 sorting...
318 converting...
319 0 add executable file in new directory
320 $ svnupanddisplay a-hg-wc 1
321 1 1 test .
322 1 1 test d1
323 1 1 test d1/a
324 revision: 1
325 author: test
326 date: * (glob)
327 msg: add executable file in new directory
328 A /d1
329 A /d1/a
330 #if execbit
331 $ test -x a-hg-wc/d1/a
332 #endif
333
334 Copy to new directory
335
336 $ mkdir a/d2
337 $ hg --cwd a cp d1/a d2/a
338 $ hg --cwd a ci -d '1 0' -A -m 'copy file to new directory'
339
340 $ hg convert -d svn a
341 assuming destination a-hg
342 initializing svn working copy 'a-hg-wc'
343 scanning source...
344 sorting...
345 converting...
346 0 copy file to new directory
347 $ svnupanddisplay a-hg-wc 1
348 2 1 test d1
349 2 1 test d1/a
350 2 2 test .
351 2 2 test d2
352 2 2 test d2/a
353 revision: 2
354 author: test
355 date: * (glob)
356 msg: copy file to new directory
357 A /d2
358 A /d2/a (from /d1/a@1)
359
360 Branchy history
361
362 $ hg init b
363 $ echo base > b/b
364 $ hg --cwd b ci -d '0 0' -Ambase
365 adding b
366
367 $ svn-safe-append.py left-1 b/b
368 $ echo left-1 > b/left-1
369 $ hg --cwd b ci -d '1 0' -Amleft-1
370 adding left-1
371
372 $ svn-safe-append.py left-2 b/b
373 $ echo left-2 > b/left-2
374 $ hg --cwd b ci -d '2 0' -Amleft-2
375 adding left-2
376
377 $ hg --cwd b up 0
378 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
379
380 $ svn-safe-append.py right-1 b/b
381 $ echo right-1 > b/right-1
382 $ hg --cwd b ci -d '3 0' -Amright-1
383 adding right-1
384 created new head
385
386 $ svn-safe-append.py right-2 b/b
387 $ echo right-2 > b/right-2
388 $ hg --cwd b ci -d '4 0' -Amright-2
389 adding right-2
390
391 $ hg --cwd b up -C 2
392 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
393 $ hg --cwd b merge
394 merging b
395 warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
396 2 files updated, 0 files merged, 0 files removed, 1 files unresolved
397 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
398 [1]
399 $ hg --cwd b revert -r 2 b
400 $ hg --cwd b resolve -m b
401 (no more unresolved files)
402 $ hg --cwd b ci -d '5 0' -m 'merge'
403
404 Expect 4 changes
405
406 $ hg convert -d svn b
407 assuming destination b-hg
408 initializing svn repository 'b-hg'
409 initializing svn working copy 'b-hg-wc'
410 scanning source...
411 sorting...
412 converting...
413 5 base
414 4 left-1
415 3 left-2
416 2 right-1
417 1 right-2
418 0 merge
419
420 $ svnupanddisplay b-hg-wc 0
421 4 2 test left-1
422 4 3 test b
423 4 3 test left-2
424 4 4 test .
425 4 4 test right-1
426 4 4 test right-2
427 revision: 4
428 author: test
429 date: * (glob)
430 msg: merge
431 A /right-1
432 A /right-2
433 revision: 3
434 author: test
435 date: * (glob)
436 msg: left-2
437 M /b
438 A /left-2
439 revision: 2
440 author: test
441 date: * (glob)
442 msg: left-1
443 M /b
444 A /left-1
445 revision: 1
446 author: test
447 date: * (glob)
448 msg: base
449 A /b
450
451 Tags are not supported, but must not break conversion
452
453 $ rm -rf a a-hg a-hg-wc
454 $ hg init a
455 $ echo a > a/a
456 $ hg --cwd a ci -d '0 0' -A -m 'Add file a'
457 adding a
458 $ hg --cwd a tag -d '1 0' -m 'Tagged as v1.0' v1.0
459
460 $ hg convert -d svn a
461 assuming destination a-hg
462 initializing svn repository 'a-hg'
463 initializing svn working copy 'a-hg-wc'
464 scanning source...
465 sorting...
466 converting...
467 1 Add file a
468 0 Tagged as v1.0
469 writing Subversion tags is not yet implemented
470 $ svnupanddisplay a-hg-wc 2
471 2 1 test a
472 2 2 test .
473 2 2 test .hgtags
474 revision: 2
475 author: test
476 date: * (glob)
477 msg: Tagged as v1.0
478 A /.hgtags
479 revision: 1
480 author: test
481 date: * (glob)
482 msg: Add file a
483 A /a
484 $ rm -rf a a-hg a-hg-wc
485
486 #if execbit
487
488 Executable bit removal
489
490 $ hg init a
491
492 $ echo a > a/exec
493 $ chmod +x a/exec
494 $ hg --cwd a ci -d '1 0' -A -m 'create executable'
495 adding exec
496 $ chmod -x a/exec
497 $ hg --cwd a ci -d '2 0' -A -m 'remove executable bit'
498
499 $ hg convert -d svn a
500 assuming destination a-hg
501 initializing svn repository 'a-hg'
502 initializing svn working copy 'a-hg-wc'
503 scanning source...
504 sorting...
505 converting...
506 1 create executable
507 0 remove executable bit
508 $ svnupanddisplay a-hg-wc 0
509 2 2 test .
510 2 2 test exec
511 revision: 2
512 author: test
513 date: * (glob)
514 msg: remove executable bit
515 M /exec
516 revision: 1
517 author: test
518 date: * (glob)
519 msg: create executable
520 A /exec
521 $ test ! -x a-hg-wc/exec
522
523 $ rm -rf a a-hg a-hg-wc
524
525 #endif
526
527 Skipping empty commits
528
529 $ hg init a
530
531 $ hg --cwd a --config ui.allowemptycommit=True ci -d '1 0' -m 'Initial empty commit'
532
533 $ echo a > a/a
534 $ hg --cwd a ci -d '0 0' -A -m 'Some change'
535 adding a
536 $ hg --cwd a --config ui.allowemptycommit=True ci -d '2 0' -m 'Empty commit 1'
537 $ hg --cwd a --config ui.allowemptycommit=True ci -d '3 0' -m 'Empty commit 2'
538 $ echo b > a/b
539 $ hg --cwd a ci -d '0 0' -A -m 'Another change'
540 adding b
541
542 $ hg convert -d svn a
543 assuming destination a-hg
544 initializing svn repository 'a-hg'
545 initializing svn working copy 'a-hg-wc'
546 scanning source...
547 sorting...
548 converting...
549 4 Initial empty commit
550 3 Some change
551 2 Empty commit 1
552 1 Empty commit 2
553 0 Another change
554
555 $ svnupanddisplay a-hg-wc 0
556 2 1 test a
557 2 2 test .
558 2 2 test b
559 revision: 2
560 author: test
561 date: * (glob)
562 msg: Another change
563 A /b
564 revision: 1
565 author: test
566 date: * (glob)
567 msg: Some change
568 A /a
569
570 $ rm -rf a a-hg a-hg-wc
571
572 Commit dates convertion
573
574 $ hg init a
575
576 $ echo a >> a/a
577 $ hg add a
578 adding a/a
579 $ hg --cwd a ci -d '1 0' -A -m 'Change 1'
580
581 $ echo a >> a/a
582 $ hg --cwd a ci -d '2 0' -m 'Change 2'
583
584 $ echo a >> a/a
585 $ hg --cwd a ci -d '2 0' -m 'Change at the same time'
586
587 $ echo a >> a/a
588 $ hg --cwd a ci -d '1 0' -m 'Change in the past'
589
590 $ echo a >> a/a
591 $ hg --cwd a ci -d '3 0' -m 'Change in the future'
592
593 $ hg convert --config convert.svn.dangerous-set-commit-dates=true -d svn a
594 assuming destination a-hg
595 initializing svn repository 'a-hg'
596 initializing svn working copy 'a-hg-wc'
597 scanning source...
598 sorting...
599 converting...
600 4 Change 1
601 3 Change 2
602 2 Change at the same time
603 1 Change in the past
604 0 Change in the future
605 $ svnupanddisplay a-hg-wc 0
606 5 5 test .
607 5 5 test a
608 revision: 5
609 author: test
610 date: 1970-01-01T00:00:03.000000Z
611 msg: Change in the future
612 M /a
613 revision: 4
614 author: test
615 date: 1970-01-01T00:00:01.000000Z
616 msg: Change in the past
617 M /a
618 revision: 3
619 author: test
620 date: 1970-01-01T00:00:02.000000Z
621 msg: Change at the same time
622 M /a
623 revision: 2
624 author: test
625 date: 1970-01-01T00:00:02.000000Z
626 msg: Change 2
627 M /a
628 revision: 1
629 author: test
630 date: 1970-01-01T00:00:01.000000Z
631 msg: Change 1
632 A /a
633
634 $ rm -rf a a-hg a-hg-wc