c8d4daad9c5072794014ffbcaacee3a4cd97ba11
[jelmer/subvertpy.git] / tests / test_fetch.py
1 # Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17 """Subversion fetch tests."""
18
19 from bzrlib.branch import Branch
20 from bzrlib.bzrdir import BzrDir
21 from bzrlib.repository import Repository
22 from bzrlib.revision import NULL_REVISION
23 from bzrlib.trace import mutter
24
25 from convert import load_dumpfile
26 from fileids import generate_svn_file_id, generate_file_id
27 import format
28 import remote
29 from scheme import TrunkBranchingScheme, NoBranchingScheme
30 from tests import TestCaseWithSubversionRepository
31 from transport import SvnRaTransport
32
33 import os
34
35 class TestFetchWorks(TestCaseWithSubversionRepository):
36     def test_fetch_fileid_renames(self):
37         repos_url = self.make_client('d', 'dc')
38         self.build_tree({'dc/test': "data"})
39         self.client_add("dc/test")
40         self.client_set_prop("dc", "bzr:file-ids", "test\tbla\n")
41         self.client_set_prop("dc", "bzr:revision-info", "")
42         self.client_commit("dc", "Msg")
43
44         oldrepos = Repository.open(repos_url)
45         dir = BzrDir.create("f", format.get_rich_root_format())
46         newrepos = dir.create_repository()
47         oldrepos.copy_content_into(newrepos)
48         self.assertEqual("bla", newrepos.get_inventory(
49             oldrepos.generate_revision_id(1, "", "none")).path2id("test"))
50
51     def test_fetch_trunk1(self):
52         repos_url = self.make_client('d', 'dc')
53         self.build_tree({'dc/proj1/trunk/file': "data"})
54         self.client_add("dc/proj1")
55         self.client_commit("dc", "My Message")
56         oldrepos = Repository.open(repos_url)
57         oldrepos.set_branching_scheme(TrunkBranchingScheme(1))
58         dir = BzrDir.create("f",format.get_rich_root_format())
59         newrepos = dir.create_repository()
60         oldrepos.copy_content_into(newrepos)
61
62     def test_fetch_null(self):
63         repos_url = self.make_client('d', 'dc')
64         oldrepos = Repository.open(repos_url)
65         oldrepos.set_branching_scheme(TrunkBranchingScheme(1))
66         dir = BzrDir.create("f", format.get_rich_root_format())
67         newrepos = dir.create_repository()
68         oldrepos.copy_content_into(newrepos, NULL_REVISION)
69
70     def test_fetch_complex_ids_dirs(self):
71         repos_url = self.make_client('d', 'dc')
72         self.build_tree({'dc/dir/adir': None})
73         self.client_add("dc/dir")
74         self.client_set_prop("dc", "bzr:revision-info", "")
75         self.client_set_prop("dc", "bzr:file-ids", "dir\tbloe\ndir/adir\tbla\n")
76         self.client_commit("dc", "My Message")
77         self.client_update("dc")
78         self.client_copy("dc/dir/adir", "dc/bdir")
79         self.client_delete("dc/dir/adir")
80         self.client_set_prop("dc", "bzr:revision-info", "properties: \n")
81         self.client_set_prop("dc", "bzr:file-ids", "bdir\tbla\n")
82         self.client_commit("dc", "My Message")
83         self.client_update("dc")
84         oldrepos = Repository.open(repos_url)
85         dir = BzrDir.create("f",format.get_rich_root_format())
86         newrepos = dir.create_repository()
87         oldrepos.copy_content_into(newrepos)
88         tree = newrepos.revision_tree(oldrepos.generate_revision_id(2, "", "none"))
89         self.assertEquals("bloe", tree.path2id("dir"))
90         self.assertIs(None, tree.path2id("dir/adir"))
91         self.assertEquals("bla", tree.path2id("bdir"))
92
93     def test_fetch_complex_ids_files(self):
94         repos_url = self.make_client('d', 'dc')
95         self.build_tree({'dc/dir/adir': 'contents'})
96         self.client_add("dc/dir")
97         self.client_set_prop("dc", "bzr:revision-info", "")
98         self.client_set_prop("dc", "bzr:file-ids", "dir\tbloe\ndir/adir\tbla\n")
99         self.client_commit("dc", "My Message")
100         self.client_update("dc")
101         self.client_copy("dc/dir/adir", "dc/bdir")
102         self.client_delete("dc/dir/adir")
103         self.client_set_prop("dc", "bzr:revision-info", "properties: \n")
104         self.client_set_prop("dc", "bzr:file-ids", "bdir\tbla\n")
105         self.client_commit("dc", "My Message")
106         self.client_update("dc")
107         oldrepos = Repository.open(repos_url)
108         dir = BzrDir.create("f",format.get_rich_root_format())
109         newrepos = dir.create_repository()
110         oldrepos.copy_content_into(newrepos)
111         tree = newrepos.revision_tree(oldrepos.generate_revision_id(2, "", "none"))
112         self.assertEquals("bloe", tree.path2id("dir"))
113         self.assertIs(None, tree.path2id("dir/adir"))
114         mutter('entries: %r' % tree.inventory.entries())
115         self.assertEquals("bla", tree.path2id("bdir"))
116
117     def test_fetch_special_char(self):
118         repos_url = self.make_client('d', 'dc')
119         self.build_tree({u'dc/trunk/f\x2cle': "data"})
120         self.client_add("dc/trunk")
121         self.client_commit("dc", "My Message")
122         oldrepos = Repository.open(repos_url)
123         oldrepos.set_branching_scheme(TrunkBranchingScheme(1))
124         dir = BzrDir.create("f",format.get_rich_root_format())
125         newrepos = dir.create_repository()
126         oldrepos.copy_content_into(newrepos)
127
128     def test_fetch_delete(self):
129         repos_url = self.make_client('d', 'dc')
130         self.build_tree({'dc/foo/bla': "data"})
131         self.client_add("dc/foo")
132         self.client_commit("dc", "My Message")
133         oldrepos = Repository.open(repos_url)
134         dir = BzrDir.create("f",format.get_rich_root_format())
135         newrepos = dir.create_repository()
136         oldrepos.copy_content_into(newrepos)
137         self.client_delete("dc/foo/bla")
138         self.client_commit("dc", "Second Message")
139         newrepos = Repository.open("f")
140         oldrepos.copy_content_into(newrepos)
141         self.assertTrue(oldrepos.has_revision(oldrepos.generate_revision_id(2, "", "none")))
142
143     def test_fetch_delete_recursive(self):
144         repos_url = self.make_client('d', 'dc')
145         self.build_tree({'dc/foo/bla': "data"})
146         self.client_add("dc/foo")
147         self.client_commit("dc", "My Message")
148         self.client_delete("dc/foo")
149         self.client_commit("dc", "Second Message")
150         oldrepos = Repository.open(repos_url)
151         dir = BzrDir.create("f", format.get_rich_root_format())
152         newrepos = dir.create_repository()
153         oldrepos.copy_content_into(newrepos)
154         tree = newrepos.revision_tree(oldrepos.generate_revision_id(1, "", "none"))
155         self.assertEquals(3, len(tree.inventory))
156         tree = newrepos.revision_tree(oldrepos.generate_revision_id(2, "", "none"))
157         self.assertEquals(1, len(tree.inventory))
158
159     def test_fetch_local(self):
160         repos_url = self.make_client('d', 'dc')
161         self.build_tree({'dc/foo/bla': "data"})
162         self.client_add("dc/foo")
163         self.client_commit("dc", "My Message")
164         self.build_tree({'dc/foo/blo': "data2", "dc/bar/foo": "data3", 'dc/foo/bla': "data"})
165         self.client_add("dc/foo/blo")
166         self.client_add("dc/bar")
167         self.client_commit("dc", "Second Message")
168         oldrepos = Repository.open(repos_url)
169         dir = BzrDir.create("f",format.get_rich_root_format())
170         newrepos = dir.create_repository()
171         oldrepos.copy_content_into(newrepos)
172         self.assertTrue(newrepos.has_revision(
173             oldrepos.generate_revision_id(1, "", "none")))
174         self.assertTrue(newrepos.has_revision(
175             oldrepos.generate_revision_id(2, "", "none")))
176         tree = newrepos.revision_tree(
177                 oldrepos.generate_revision_id(2, "", "none"))
178         self.assertTrue(tree.has_filename("foo/bla"))
179         self.assertTrue(tree.has_filename("foo"))
180         self.assertEqual("data", tree.get_file_by_path("foo/bla").read())
181
182     def test_fetch_replace(self):
183         repos_url = self.make_client('d', 'dc')
184         self.build_tree({'dc/bla': "data"})
185         self.client_add("dc/bla")
186         self.client_commit("dc", "My Message")
187         self.client_delete("dc/bla")
188         self.build_tree({'dc/bla': "data2"})
189         self.client_add("dc/bla")
190         self.client_commit("dc", "Second Message")
191         oldrepos = Repository.open("svn+"+repos_url)
192         dir = BzrDir.create("f",format.get_rich_root_format())
193         newrepos = dir.create_repository()
194         oldrepos.copy_content_into(newrepos)
195         self.assertTrue(newrepos.has_revision(
196             oldrepos.generate_revision_id(1, "", "none")))
197         self.assertTrue(newrepos.has_revision(
198             oldrepos.generate_revision_id(2, "", "none")))
199         inv1 = newrepos.get_inventory(
200                 oldrepos.generate_revision_id(1, "", "none"))
201         inv2 = newrepos.get_inventory(
202                 oldrepos.generate_revision_id(2, "", "none"))
203         self.assertNotEqual(inv1.path2id("bla"), inv2.path2id("bla"))
204
205     def test_fetch_copy_subdir(self):
206         repos_url = self.make_client('d', 'dc')
207         self.build_tree({'dc/trunk/mydir/a': "data"})
208         self.client_add("dc/trunk")
209         self.client_commit("dc", "My Message")
210         self.build_tree({'dc/branches/tmp': None})
211         self.client_add("dc/branches")
212         self.client_commit("dc", "Second Message")
213         self.client_copy("dc/trunk/mydir", "dc/branches/tmp/abranch")
214         self.client_commit("dc", "Third Message")
215         oldrepos = Repository.open("svn+"+repos_url)
216         oldrepos.set_branching_scheme(TrunkBranchingScheme())
217         dir = BzrDir.create("f",format.get_rich_root_format())
218         newrepos = dir.create_repository()
219         oldrepos.copy_content_into(newrepos)
220
221     def test_fetch_replace_nordic(self):
222         filename = os.path.join(self.test_dir, "dumpfile")
223         open(filename, 'w').write("""SVN-fs-dump-format-version: 2
224
225 UUID: 606c7b1f-987c-4826-b37d-eb556ceb87e1
226
227 Revision-number: 0
228 Prop-content-length: 56
229 Content-length: 56
230
231 K 8
232 svn:date
233 V 27
234 2006-12-26T00:04:55.850520Z
235 PROPS-END
236
237 Revision-number: 1
238 Prop-content-length: 103
239 Content-length: 103
240
241 K 7
242 svn:log
243 V 3
244 add
245 K 10
246 svn:author
247 V 6
248 jelmer
249 K 8
250 svn:date
251 V 27
252 2006-12-26T00:05:15.504335Z
253 PROPS-END
254
255 Node-path: x\xc3\xa1
256 Node-kind: dir
257 Node-action: add
258 Prop-content-length: 10
259 Content-length: 10
260
261 PROPS-END
262
263 Node-path: u\xc3\xa1
264 Node-path: bla
265 Node-kind: file
266 Node-action: add
267 Prop-content-length: 10
268 Text-content-length: 5
269 Text-content-md5: 49803c8f7913948eb3e30bae749ae6bd
270 Content-length: 15
271
272 PROPS-END
273 bloe
274
275
276 Revision-number: 2
277 Prop-content-length: 105
278 Content-length: 105
279
280 K 7
281 svn:log
282 V 5
283 readd
284 K 10
285 svn:author
286 V 6
287 jelmer
288 K 8
289 svn:date
290 V 27
291 2006-12-26T00:05:43.584249Z
292 PROPS-END
293
294 Node-path: x\xc3\xa1
295 Node-action: delete
296
297 """)
298         os.mkdir("old")
299
300         load_dumpfile("dumpfile", "old")
301         oldrepos = Repository.open("old")
302         dir = BzrDir.create("f",format.get_rich_root_format())
303         newrepos = dir.create_repository()
304         oldrepos.copy_content_into(newrepos)
305         self.assertTrue(newrepos.has_revision(
306             oldrepos.generate_revision_id(1, "", "none")))
307         inv1 = newrepos.get_inventory(
308                 oldrepos.generate_revision_id(1, "", "none"))
309         self.assertTrue(inv1.has_filename(u"x\xe1"))
310
311     def test_fetch_replace_with_subreplace(self):
312         filename = os.path.join(self.test_dir, "dumpfile")
313         open(filename, 'w').write("""SVN-fs-dump-format-version: 2
314
315 UUID: 606c7b1f-987c-4826-b37d-eb456ceb87e1
316
317 Revision-number: 0
318 Prop-content-length: 56
319 Content-length: 56
320
321 K 8
322 svn:date
323 V 27
324 2006-12-26T00:04:55.850520Z
325 PROPS-END
326
327 Revision-number: 1
328 Prop-content-length: 103
329 Content-length: 103
330
331 K 7
332 svn:log
333 V 3
334 add
335 K 10
336 svn:author
337 V 6
338 jelmer
339 K 8
340 svn:date
341 V 27
342 2006-12-26T00:05:15.504335Z
343 PROPS-END
344
345 Node-path: x
346 Node-kind: dir
347 Node-action: add
348 Prop-content-length: 10
349 Content-length: 10
350
351 PROPS-END
352
353 Node-path: x/t
354 Node-kind: dir
355 Node-action: add
356 Prop-content-length: 10
357 Content-length: 10
358
359 PROPS-END
360
361 Node-path: u
362 Node-kind: dir
363 Node-action: add
364 Prop-content-length: 10
365 Content-length: 10
366
367 PROPS-END
368
369 Revision-number: 2
370 Prop-content-length: 105
371 Content-length: 105
372
373 K 7
374 svn:log
375 V 5
376 readd
377 K 10
378 svn:author
379 V 6
380 jelmer
381 K 8
382 svn:date
383 V 27
384 2006-12-26T00:05:43.584249Z
385 PROPS-END
386
387 Node-path: x
388 Node-action: delete
389
390 Node-path: x
391 Node-kind: dir
392 Node-action: add
393 Prop-content-length: 10
394 Content-length: 10
395
396 PROPS-END
397
398
399 Revision-number: 3
400 Prop-content-length: 108
401 Content-length: 108
402
403 K 7
404 svn:log
405 V 8
406 Replace
407
408 K 10
409 svn:author
410 V 6
411 jelmer
412 K 8
413 svn:date
414 V 27
415 2006-12-25T04:30:06.383777Z
416 PROPS-END
417
418 Node-path: x
419 Node-action: delete
420
421 Node-path: y
422 Node-kind: dir
423 Node-action: add
424 Node-copyfrom-rev: 1
425 Node-copyfrom-path: x
426
427 Node-path: y/t
428 Node-action: delete
429
430 Node-path: y/t
431 Node-kind: dir
432 Node-action: add
433 Node-copyfrom-rev: 1
434 Node-copyfrom-path: u
435
436
437 """)
438         os.mkdir("old")
439
440         load_dumpfile("dumpfile", "old")
441         oldrepos = Repository.open("old")
442         dir = BzrDir.create("f",format.get_rich_root_format())
443         newrepos = dir.create_repository()
444         oldrepos.copy_content_into(newrepos)
445         self.assertTrue(newrepos.has_revision(
446             oldrepos.generate_revision_id(1, "", "none")))
447         self.assertTrue(newrepos.has_revision(
448             oldrepos.generate_revision_id(3, "", "none")))
449         inv1 = newrepos.get_inventory(
450                 oldrepos.generate_revision_id(1, "", "none"))
451         inv2 = newrepos.get_inventory(
452                 oldrepos.generate_revision_id(3, "", "none"))
453
454     def test_fetch_replace_self(self):
455         filename = os.path.join(self.test_dir, "dumpfile")
456         open(filename, 'w').write("""SVN-fs-dump-format-version: 2
457
458 UUID: 6dcc86fc-ac21-4df7-a3a3-87616123c853
459
460 Revision-number: 0
461 Prop-content-length: 56
462 Content-length: 56
463
464 K 8
465 svn:date
466 V 27
467 2006-12-25T04:27:54.633666Z
468 PROPS-END
469
470 Revision-number: 1
471 Prop-content-length: 108
472 Content-length: 108
473
474 K 7
475 svn:log
476 V 8
477 Add dir
478
479 K 10
480 svn:author
481 V 6
482 jelmer
483 K 8
484 svn:date
485 V 27
486 2006-12-25T04:28:17.503039Z
487 PROPS-END
488
489 Node-path: bla
490 Node-kind: dir
491 Node-action: add
492 Prop-content-length: 10
493 Content-length: 10
494
495 PROPS-END
496
497
498 Revision-number: 2
499 Prop-content-length: 117
500 Content-length: 117
501
502 K 7
503 svn:log
504 V 16
505 Add another dir
506
507 K 10
508 svn:author
509 V 6
510 jelmer
511 K 8
512 svn:date
513 V 27
514 2006-12-25T04:28:30.160663Z
515 PROPS-END
516
517 Node-path: blie
518 Node-kind: dir
519 Node-action: add
520 Prop-content-length: 10
521 Content-length: 10
522
523 PROPS-END
524
525
526 Revision-number: 3
527 Prop-content-length: 105
528 Content-length: 105
529
530 K 7
531 svn:log
532 V 5
533 Copy
534
535 K 10
536 svn:author
537 V 6
538 jelmer
539 K 8
540 svn:date
541 V 27
542 2006-12-25T04:28:44.996894Z
543 PROPS-END
544
545 Node-path: bloe
546 Node-kind: dir
547 Node-action: add
548 Node-copyfrom-rev: 1
549 Node-copyfrom-path: bla
550
551
552 Revision-number: 4
553 Prop-content-length: 108
554 Content-length: 108
555
556 K 7
557 svn:log
558 V 8
559 Replace
560
561 K 10
562 svn:author
563 V 6
564 jelmer
565 K 8
566 svn:date
567 V 27
568 2006-12-25T04:30:06.383777Z
569 PROPS-END
570
571 Node-path: bla
572 Node-action: delete
573
574
575 Node-path: bla
576 Node-kind: dir
577 Node-action: add
578 Node-copyfrom-rev: 2
579 Node-copyfrom-path: bla
580
581
582 """)
583         os.mkdir("old")
584
585         load_dumpfile("dumpfile", "old")
586         oldrepos = Repository.open("old")
587         dir = BzrDir.create("f",format.get_rich_root_format())
588         newrepos = dir.create_repository()
589         oldrepos.copy_content_into(newrepos)
590         self.assertTrue(newrepos.has_revision(
591             oldrepos.generate_revision_id(1, "", "none")))
592         self.assertTrue(newrepos.has_revision(
593             oldrepos.generate_revision_id(3, "", "none")))
594         inv1 = newrepos.get_inventory(
595                 oldrepos.generate_revision_id(1, "", "none"))
596         inv2 = newrepos.get_inventory(
597                 oldrepos.generate_revision_id(3, "", "none"))
598         self.assertEqual(inv1.path2id("bla"), inv2.path2id("bla"))
599
600     def test_fetch_replace_backup(self):
601         filename = os.path.join(self.test_dir, "dumpfile")
602         open(filename, 'w').write("""SVN-fs-dump-format-version: 2
603
604 UUID: 6dcc86fc-ac21-4df7-a3a3-87616123c853
605
606 Revision-number: 0
607 Prop-content-length: 56
608 Content-length: 56
609
610 K 8
611 svn:date
612 V 27
613 2006-12-25T04:27:54.633666Z
614 PROPS-END
615
616 Revision-number: 1
617 Prop-content-length: 108
618 Content-length: 108
619
620 K 7
621 svn:log
622 V 8
623 Add dir
624
625 K 10
626 svn:author
627 V 6
628 jelmer
629 K 8
630 svn:date
631 V 27
632 2006-12-25T04:28:17.503039Z
633 PROPS-END
634
635 Node-path: bla
636 Node-kind: dir
637 Node-action: add
638 Prop-content-length: 10
639 Content-length: 10
640
641 PROPS-END
642
643
644 Revision-number: 2
645 Prop-content-length: 117
646 Content-length: 117
647
648 K 7
649 svn:log
650 V 16
651 Add another dir
652
653 K 10
654 svn:author
655 V 6
656 jelmer
657 K 8
658 svn:date
659 V 27
660 2006-12-25T04:28:30.160663Z
661 PROPS-END
662
663 Node-path: blie
664 Node-kind: dir
665 Node-action: add
666 Prop-content-length: 10
667 Content-length: 10
668
669 PROPS-END
670
671
672 Revision-number: 3
673 Prop-content-length: 105
674 Content-length: 105
675
676 K 7
677 svn:log
678 V 5
679 Copy
680
681 K 10
682 svn:author
683 V 6
684 jelmer
685 K 8
686 svn:date
687 V 27
688 2006-12-25T04:28:44.996894Z
689 PROPS-END
690
691 Node-path: bloe
692 Node-kind: dir
693 Node-action: add
694 Node-copyfrom-rev: 1
695 Node-copyfrom-path: bla
696
697
698 Revision-number: 4
699 Prop-content-length: 112
700 Content-length: 112
701
702 K 7
703 svn:log
704 V 11
705 Change bla
706
707 K 10
708 svn:author
709 V 6
710 jelmer
711 K 8
712 svn:date
713 V 27
714 2006-12-25T23:51:09.678679Z
715 PROPS-END
716
717 Node-path: bla
718 Node-kind: dir
719 Node-action: change
720 Prop-content-length: 28
721 Content-length: 28
722
723 K 3
724 foo
725 V 5
726 bloe
727
728 PROPS-END
729
730
731 Revision-number: 5
732 Prop-content-length: 108
733 Content-length: 108
734
735 K 7
736 svn:log
737 V 8
738 Replace
739
740 K 10
741 svn:author
742 V 6
743 jelmer
744 K 8
745 svn:date
746 V 27
747 2006-12-25T04:30:06.383777Z
748 PROPS-END
749
750 Node-path: bla
751 Node-action: delete
752
753
754 Node-path: bla
755 Node-kind: dir
756 Node-action: add
757 Node-copyfrom-rev: 1
758 Node-copyfrom-path: bla
759
760
761 """)
762         os.mkdir("old")
763
764         load_dumpfile("dumpfile", "old")
765         oldrepos = Repository.open("old")
766         dir = BzrDir.create("f",format.get_rich_root_format())
767         newrepos = dir.create_repository()
768         oldrepos.copy_content_into(newrepos)
769         self.assertTrue(newrepos.has_revision(
770             oldrepos.generate_revision_id(1, "", "none")))
771         self.assertTrue(newrepos.has_revision(
772             oldrepos.generate_revision_id(3, "", "none")))
773         inv1 = newrepos.get_inventory(
774                 oldrepos.generate_revision_id(1, "", "none"))
775         inv2 = newrepos.get_inventory(
776                 oldrepos.generate_revision_id(3, "", "none"))
777         self.assertEqual(inv1.path2id("bla"), inv2.path2id("bla"))
778
779     def test_fetch_replace_unrelated(self):
780         filename = os.path.join(self.test_dir, "dumpfile")
781         open(filename, 'w').write("""SVN-fs-dump-format-version: 2
782
783 UUID: 606c7b1f-987c-4826-b37d-eb456ceb87e1
784
785 Revision-number: 0
786 Prop-content-length: 56
787 Content-length: 56
788
789 K 8
790 svn:date
791 V 27
792 2006-12-26T00:04:55.850520Z
793 PROPS-END
794
795 Revision-number: 1
796 Prop-content-length: 103
797 Content-length: 103
798
799 K 7
800 svn:log
801 V 3
802 add
803 K 10
804 svn:author
805 V 6
806 jelmer
807 K 8
808 svn:date
809 V 27
810 2006-12-26T00:05:15.504335Z
811 PROPS-END
812
813 Node-path: x
814 Node-kind: dir
815 Node-action: add
816 Prop-content-length: 10
817 Content-length: 10
818
819 PROPS-END
820
821
822 Revision-number: 2
823 Prop-content-length: 102
824 Content-length: 102
825
826 K 7
827 svn:log
828 V 2
829 rm
830 K 10
831 svn:author
832 V 6
833 jelmer
834 K 8
835 svn:date
836 V 27
837 2006-12-26T00:05:30.775369Z
838 PROPS-END
839
840 Node-path: x
841 Node-action: delete
842
843
844 Revision-number: 3
845 Prop-content-length: 105
846 Content-length: 105
847
848 K 7
849 svn:log
850 V 5
851 readd
852 K 10
853 svn:author
854 V 6
855 jelmer
856 K 8
857 svn:date
858 V 27
859 2006-12-26T00:05:43.584249Z
860 PROPS-END
861
862 Node-path: x
863 Node-kind: dir
864 Node-action: add
865 Prop-content-length: 10
866 Content-length: 10
867
868 PROPS-END
869
870
871 Revision-number: 4
872 Prop-content-length: 108
873 Content-length: 108
874
875 K 7
876 svn:log
877 V 8
878 Replace
879
880 K 10
881 svn:author
882 V 6
883 jelmer
884 K 8
885 svn:date
886 V 27
887 2006-12-25T04:30:06.383777Z
888 PROPS-END
889
890 Node-path: x
891 Node-action: delete
892
893
894 Node-path: x
895 Node-kind: dir
896 Node-action: add
897 Node-copyfrom-rev: 1
898 Node-copyfrom-path: x
899
900                 
901 """)
902         os.mkdir("old")
903
904         load_dumpfile("dumpfile", "old")
905         oldrepos = Repository.open("old")
906         dir = BzrDir.create("f",format.get_rich_root_format())
907         newrepos = dir.create_repository()
908         oldrepos.copy_content_into(newrepos)
909         self.assertTrue(newrepos.has_revision(
910             oldrepos.generate_revision_id(1, "", "none")))
911         self.assertTrue(newrepos.has_revision(
912             oldrepos.generate_revision_id(4, "", "none")))
913         inv1 = newrepos.get_inventory(
914                 oldrepos.generate_revision_id(1, "", "none"))
915         inv2 = newrepos.get_inventory(
916                 oldrepos.generate_revision_id(4, "", "none"))
917         self.assertNotEqual(inv1.path2id("x"), inv2.path2id("x"))
918
919     def test_fetch_replace_related(self):
920         filename = os.path.join(self.test_dir, "dumpfile")
921         open(filename, 'w').write("""SVN-fs-dump-format-version: 2
922
923 UUID: 606c7b1f-987c-4826-b37d-eb456ceb87e1
924
925 Revision-number: 0
926 Prop-content-length: 56
927 Content-length: 56
928
929 K 8
930 svn:date
931 V 27
932 2006-12-26T00:04:55.850520Z
933 PROPS-END
934
935 Revision-number: 1
936 Prop-content-length: 103
937 Content-length: 103
938
939 K 7
940 svn:log
941 V 3
942 add
943 K 10
944 svn:author
945 V 6
946 jelmer
947 K 8
948 svn:date
949 V 27
950 2006-12-26T00:05:15.504335Z
951 PROPS-END
952
953 Node-path: x
954 Node-kind: dir
955 Node-action: add
956 Prop-content-length: 10
957 Content-length: 10
958
959 PROPS-END
960
961
962 Revision-number: 2
963 Prop-content-length: 102
964 Content-length: 102
965
966 K 7
967 svn:log
968 V 2
969 rm
970 K 10
971 svn:author
972 V 6
973 jelmer
974 K 8
975 svn:date
976 V 27
977 2006-12-26T00:05:30.775369Z
978 PROPS-END
979
980 Node-path: x
981 Node-action: delete
982
983
984 Revision-number: 3
985 Prop-content-length: 105
986 Content-length: 105
987
988 K 7
989 svn:log
990 V 5
991 readd
992 K 10
993 svn:author
994 V 6
995 jelmer
996 K 8
997 svn:date
998 V 27
999 2006-12-26T00:05:43.584249Z
1000 PROPS-END
1001
1002 Node-path: y
1003 Node-kind: dir
1004 Node-action: add
1005 Node-copyfrom-rev: 1
1006 Node-copyfrom-path: x
1007 Prop-content-length: 10
1008 Content-length: 10
1009
1010 PROPS-END
1011
1012
1013 Revision-number: 4
1014 Prop-content-length: 108
1015 Content-length: 108
1016
1017 K 7
1018 svn:log
1019 V 8
1020 Replace
1021
1022 K 10
1023 svn:author
1024 V 6
1025 jelmer
1026 K 8
1027 svn:date
1028 V 27
1029 2006-12-25T04:30:06.383777Z
1030 PROPS-END
1031
1032 Node-path: y
1033 Node-action: delete
1034
1035
1036 Revision-number: 5
1037 Prop-content-length: 108
1038 Content-length: 108
1039
1040 K 7
1041 svn:log
1042 V 8
1043 Replace
1044
1045 K 10
1046 svn:author
1047 V 6
1048 jelmer
1049 K 8
1050 svn:date
1051 V 27
1052 2006-12-25T04:30:06.383777Z
1053 PROPS-END
1054
1055
1056 Node-path: y
1057 Node-kind: dir
1058 Node-action: add
1059 Node-copyfrom-rev: 1
1060 Node-copyfrom-path: x
1061
1062
1063 """)
1064         os.mkdir("old")
1065
1066         load_dumpfile("dumpfile", "old")
1067         oldrepos = Repository.open("old")
1068         dir = BzrDir.create("f",format.get_rich_root_format())
1069         newrepos = dir.create_repository()
1070         oldrepos.copy_content_into(newrepos)
1071         self.assertTrue(newrepos.has_revision(
1072             oldrepos.generate_revision_id(1, "", "none")))
1073         self.assertTrue(newrepos.has_revision(
1074             oldrepos.generate_revision_id(5, "", "none")))
1075         inv1 = newrepos.get_inventory(
1076                 oldrepos.generate_revision_id(1, "", "none"))
1077         inv2 = newrepos.get_inventory(
1078                 oldrepos.generate_revision_id(5, "", "none"))
1079         self.assertNotEqual(inv1.path2id("y"), inv2.path2id("y"))
1080
1081     def test_fetch_dir_upgrade(self):
1082         repos_url = self.make_client('d', 'dc')
1083
1084         self.build_tree({'dc/trunk/lib/file': 'data'})
1085         self.client_add("dc/trunk")
1086         self.client_commit("dc", "trunk data")
1087
1088         self.build_tree({'dc/branches': None})
1089         self.client_add("dc/branches")
1090         self.client_copy("dc/trunk/lib", "dc/branches/mybranch")
1091         self.client_commit("dc", "split out lib")
1092
1093         oldrepos = Repository.open(repos_url)
1094         oldrepos.set_branching_scheme(TrunkBranchingScheme())
1095         dir = BzrDir.create("f",format.get_rich_root_format())
1096         newrepos = dir.create_repository()
1097         oldrepos.copy_content_into(newrepos)
1098
1099         branch = Branch.open("%s/branches/mybranch" % repos_url)
1100         self.assertEqual([oldrepos.generate_revision_id(2, "branches/mybranch", "trunk0")], 
1101                          branch.revision_history())
1102
1103     def test_fetch_file_from_non_branch(self):
1104         repos_url = self.make_client('d', 'dc')
1105
1106         self.build_tree({'dc/old-trunk/lib/file': 'data'})
1107         self.client_add("dc/old-trunk")
1108         self.client_commit("dc", "trunk data")
1109
1110         self.build_tree({'dc/trunk/lib': None})
1111         self.client_add("dc/trunk")
1112         self.client_copy("dc/old-trunk/lib/file", "dc/trunk/lib/file")
1113         self.client_commit("dc", "revive old trunk")
1114
1115         oldrepos = Repository.open(repos_url)
1116         oldrepos.set_branching_scheme(TrunkBranchingScheme())
1117         dir = BzrDir.create("f",format.get_rich_root_format())
1118         newrepos = dir.create_repository()
1119         oldrepos.copy_content_into(newrepos)
1120
1121         branch = Branch.open("%s/trunk" % repos_url)
1122         self.assertEqual([oldrepos.generate_revision_id(2, "trunk", "trunk0")], 
1123                          branch.revision_history())
1124
1125     def test_fetch_dir_from_non_branch(self):
1126         repos_url = self.make_client('d', 'dc')
1127
1128         self.build_tree({'dc/old-trunk/lib/file': 'data'})
1129         self.client_add("dc/old-trunk")
1130         self.client_commit("dc", "trunk data")
1131
1132         self.build_tree({'dc/trunk': None})
1133         self.client_add("dc/trunk")
1134         self.client_copy("dc/old-trunk/lib", "dc/trunk")
1135         self.client_commit("dc", "revive old trunk")
1136
1137         oldrepos = Repository.open(repos_url)
1138         oldrepos.set_branching_scheme(TrunkBranchingScheme())
1139         dir = BzrDir.create("f",format.get_rich_root_format())
1140         newrepos = dir.create_repository()
1141         oldrepos.copy_content_into(newrepos)
1142
1143         branch = Branch.open("%s/trunk" % repos_url)
1144         self.assertEqual([oldrepos.generate_revision_id(2, "trunk", "trunk0")],
1145                          branch.revision_history())
1146
1147     def test_fetch_from_non_branch(self):
1148         repos_url = self.make_client('d', 'dc')
1149
1150         self.build_tree({'dc/old-trunk/lib/file': 'data'})
1151         self.client_add("dc/old-trunk")
1152         self.client_commit("dc", "trunk data")
1153
1154         self.client_copy("dc/old-trunk", "dc/trunk")
1155         self.client_commit("dc", "revive old trunk")
1156
1157         oldrepos = Repository.open(repos_url)
1158         oldrepos.set_branching_scheme(TrunkBranchingScheme())
1159         dir = BzrDir.create("f",format.get_rich_root_format())
1160         newrepos = dir.create_repository()
1161         oldrepos.copy_content_into(newrepos)
1162
1163         branch = Branch.open("%s/trunk" % repos_url)
1164         self.assertEqual([oldrepos.generate_revision_id(2, "trunk", "trunk0")],
1165                          branch.revision_history())
1166
1167
1168
1169     def test_fetch_branch_downgrade(self):
1170         repos_url = self.make_client('d', 'dc')
1171
1172         self.build_tree({'dc/trunk/file': 'data'})
1173         self.client_add("dc/trunk")
1174         self.client_commit("dc", "trunk data")
1175
1176         self.build_tree({'dc/branches/mybranch': None})
1177         self.client_add("dc/branches")
1178         self.client_copy("dc/trunk", "dc/branches/mybranch/lib")
1179         self.client_commit("dc", "split out lib")
1180
1181         oldrepos = Repository.open(repos_url)
1182         oldrepos.set_branching_scheme(TrunkBranchingScheme())
1183         dir = BzrDir.create("f",format.get_rich_root_format())
1184         newrepos = dir.create_repository()
1185         oldrepos.copy_content_into(newrepos)
1186
1187     def test_fetch_all(self):
1188         repos_url = self.make_client('d', 'dc')
1189
1190         self.build_tree({'dc/trunk': None, 
1191                          'dc/trunk/hosts': 'hej1'})
1192         self.client_add("dc/trunk")
1193         self.client_commit("dc", "created trunk and added hosts") #1
1194
1195         self.build_tree({'dc/trunk/hosts': 'hej2'})
1196         self.client_commit("dc", "rev 2") #2
1197
1198         self.build_tree({'dc/trunk/hosts': 'hej3'})
1199         self.client_commit("dc", "rev 3") #3
1200
1201         self.build_tree({'dc/branches/foobranch/file': 'foohosts'})
1202         self.client_add("dc/branches")
1203         self.client_commit("dc", "foohosts") #4
1204
1205         oldrepos = Repository.open(repos_url)
1206         oldrepos.set_branching_scheme(TrunkBranchingScheme())
1207         dir = BzrDir.create("f",format.get_rich_root_format())
1208         newrepos = dir.create_repository()
1209         oldrepos.copy_content_into(newrepos)
1210
1211         self.assertTrue(newrepos.has_revision(
1212             oldrepos.generate_revision_id(1, "trunk", "trunk0")))
1213         self.assertTrue(newrepos.has_revision(
1214             oldrepos.generate_revision_id(2, "trunk", "trunk0")))
1215         self.assertTrue(newrepos.has_revision(
1216             oldrepos.generate_revision_id(3, "trunk", "trunk0")))
1217         self.assertTrue(newrepos.has_revision(
1218             oldrepos.generate_revision_id(4, "branches/foobranch", "trunk0")))
1219         self.assertFalse(newrepos.has_revision(
1220             oldrepos.generate_revision_id(4, "trunk", "trunk0")))
1221         self.assertFalse(newrepos.has_revision(
1222             oldrepos.generate_revision_id(2, "", "trunk0")))
1223
1224     def test_fetch_copy_root_id_kept(self):
1225         repos_url = self.make_client('d', 'dc')
1226
1227         self.build_tree({'dc/trunk': None, 
1228                          'dc/trunk/hosts': 'hej1'})
1229         self.client_add("dc/trunk")
1230         self.client_commit("dc", "created trunk and added hosts") #1
1231
1232         self.build_tree({'dc/branches': None})
1233         self.client_add("dc/branches")
1234         self.client_commit("dc", "added branches") #2
1235
1236         self.client_copy("dc/trunk", "dc/branches/foobranch")
1237         self.client_commit("dc", "added branch foobranch") #3
1238
1239         repos = remote.SvnRemoteAccess(SvnRaTransport("svn+"+repos_url), format.SvnRemoteFormat()).find_repository()
1240
1241         tree = repos.revision_tree(
1242              repos.generate_revision_id(3, "branches/foobranch", "trunk0"))
1243
1244         self.assertEqual(generate_svn_file_id(repos.uuid, 1, "trunk", ""), tree.inventory.root.file_id)
1245
1246     def test_fetch_odd(self):
1247         repos_url = self.make_client('d', 'dc')
1248
1249         self.build_tree({'dc/trunk': None, 
1250                          'dc/trunk/hosts': 'hej1'})
1251         self.client_add("dc/trunk")
1252         self.client_commit("dc", "created trunk and added hosts") #1
1253         self.client_update("dc")
1254
1255         self.build_tree({'dc/trunk/hosts': 'hej2'})
1256         self.client_commit("dc", "rev 2") #2
1257         self.client_update("dc")
1258
1259         self.build_tree({'dc/trunk/hosts': 'hej3'})
1260         self.client_commit("dc", "rev 3") #3
1261         self.client_update("dc")
1262
1263         self.build_tree({'dc/branches': None})
1264         self.client_add("dc/branches")
1265         self.client_commit("dc", "added branches") #4
1266         self.client_update("dc")
1267
1268         self.client_copy("dc/trunk", "dc/branches/foobranch")
1269         self.client_commit("dc", "added branch foobranch") #5
1270         self.client_update("dc")
1271
1272         self.build_tree({'dc/branches/foobranch/hosts': 'foohosts'})
1273         self.client_commit("dc", "foohosts") #6
1274
1275         repos = remote.SvnRemoteAccess(SvnRaTransport("svn+"+repos_url), format.SvnRemoteFormat()).find_repository()
1276
1277         tree = repos.revision_tree(
1278              repos.generate_revision_id(6, "branches/foobranch", "trunk0"))
1279
1280     def test_fetch_consistent(self):
1281         repos_url = self.make_client('d', 'dc')
1282         self.build_tree({'dc/bla': "data"})
1283         self.client_add("dc/bla")
1284         self.client_set_prop("dc/bla", "svn:executable", "*")
1285         self.client_commit("dc", "My Message")
1286         oldrepos = Repository.open("svn+"+repos_url)
1287         dir1 = BzrDir.create("f",format.get_rich_root_format())
1288         dir2 = BzrDir.create("g",format.get_rich_root_format())
1289         newrepos1 = dir1.create_repository()
1290         newrepos2 = dir2.create_repository()
1291         oldrepos.copy_content_into(newrepos1)
1292         oldrepos.copy_content_into(newrepos2)
1293         inv1 = newrepos1.get_inventory(
1294                 oldrepos.generate_revision_id(1, "", "none"))
1295         inv2 = newrepos2.get_inventory(
1296                 oldrepos.generate_revision_id(1, "", "none"))
1297         self.assertEqual(inv1, inv2)
1298
1299     def test_fetch_executable(self):
1300         repos_url = self.make_client('d', 'dc')
1301         self.build_tree({'dc/bla': "data", 'dc/blie': "data2"})
1302         self.client_add("dc/bla")
1303         self.client_add("dc/blie")
1304         self.client_set_prop("dc/bla", "svn:executable", "*")
1305         self.client_set_prop("dc/blie", "svn:executable", "")
1306         self.client_commit("dc", "My Message")
1307         oldrepos = Repository.open("svn+"+repos_url)
1308         dir = BzrDir.create("f",format.get_rich_root_format())
1309         newrepos = dir.create_repository()
1310         oldrepos.copy_content_into(newrepos)
1311         self.assertTrue(newrepos.has_revision(
1312             oldrepos.generate_revision_id(1, "", "none")))
1313         inv1 = newrepos.get_inventory(
1314                 oldrepos.generate_revision_id(1, "", "none"))
1315         self.assertTrue(inv1[inv1.path2id("bla")].executable)
1316         self.assertTrue(inv1[inv1.path2id("blie")].executable)
1317
1318     def test_fetch_symlink(self):
1319         repos_url = self.make_client('d', 'dc')
1320         self.build_tree({'dc/bla': "data"})
1321         os.symlink('bla', 'dc/mylink')
1322         self.client_add("dc/bla")
1323         self.client_add("dc/mylink")
1324         self.client_commit("dc", "My Message")
1325         oldrepos = Repository.open("svn+"+repos_url)
1326         dir = BzrDir.create("f",format.get_rich_root_format())
1327         newrepos = dir.create_repository()
1328         oldrepos.copy_content_into(newrepos)
1329         self.assertTrue(newrepos.has_revision(
1330             oldrepos.generate_revision_id(1, "", "none")))
1331         inv1 = newrepos.get_inventory(
1332                 oldrepos.generate_revision_id(1, "", "none"))
1333         self.assertEqual('symlink', inv1[inv1.path2id("mylink")].kind)
1334         self.assertEqual('bla', inv1[inv1.path2id("mylink")].symlink_target)
1335
1336
1337     def test_fetch_executable_separate(self):
1338         repos_url = self.make_client('d', 'dc')
1339         self.build_tree({'dc/bla': "data"})
1340         self.client_add("dc/bla")
1341         self.client_commit("dc", "My Message")
1342         self.client_set_prop("dc/bla", "svn:executable", "*")
1343         self.client_commit("dc", "Make executable")
1344         oldrepos = Repository.open("svn+"+repos_url)
1345         dir = BzrDir.create("f",format.get_rich_root_format())
1346         newrepos = dir.create_repository()
1347         oldrepos.copy_content_into(newrepos)
1348         self.assertTrue(newrepos.has_revision(
1349             oldrepos.generate_revision_id(1, "", "none")))
1350         inv1 = newrepos.get_inventory(
1351                 oldrepos.generate_revision_id(1, "", "none"))
1352         self.assertFalse(inv1[inv1.path2id("bla")].executable)
1353         inv2 = newrepos.get_inventory(
1354                 oldrepos.generate_revision_id(2, "", "none"))
1355         self.assertTrue(inv2[inv2.path2id("bla")].executable)
1356         self.assertEqual(oldrepos.generate_revision_id(2, "", "none"), 
1357                          inv2[inv2.path2id("bla")].revision)
1358
1359     def test_fetch_ghosts(self):
1360         repos_url = self.make_client('d', 'dc')
1361         self.build_tree({'dc/bla': "data"})
1362         self.client_add("dc/bla")
1363         self.client_set_prop("dc", "bzr:ancestry:v3-none", "aghost\n")
1364         self.client_commit("dc", "My Message")
1365         oldrepos = Repository.open("svn+"+repos_url)
1366         dir = BzrDir.create("f",format.get_rich_root_format())
1367         newrepos = dir.create_repository()
1368         oldrepos.copy_content_into(newrepos)
1369
1370         rev = newrepos.get_revision(oldrepos.generate_revision_id(1, "", "none"))
1371         self.assertTrue("aghost" in rev.parent_ids)
1372
1373     def test_fetch_svk_merge(self):
1374         repos_url = self.make_client('d', 'dc')
1375         self.build_tree({'dc/trunk/bla': "data", "dc/branches": None})
1376         self.client_add("dc/trunk")
1377         self.client_commit("dc", "My Message")
1378
1379         self.client_add("dc/branches")
1380         self.client_copy("dc/trunk", "dc/branches/foo")
1381         self.build_tree({'dc/branches/foo/bla': "more data"})
1382         self.client_commit("dc", "Branch")
1383
1384         oldrepos = Repository.open("svn+"+repos_url)
1385         self.client_set_prop("dc/trunk", "svk:merge", 
1386                              "%s:/branches/foo:2\n" % oldrepos.uuid)
1387         self.client_commit("dc", "Merge")
1388
1389         dir = BzrDir.create("f",format.get_rich_root_format())
1390         newrepos = dir.create_repository()
1391         oldrepos.copy_content_into(newrepos)
1392
1393         rev = newrepos.get_revision(oldrepos.generate_revision_id(3, "trunk", "trunk0"))
1394         mutter('parent ids: %r' % rev.parent_ids)
1395         self.assertTrue(oldrepos.generate_revision_id(2, "branches/foo", "trunk0") in rev.parent_ids)
1396
1397     def test_fetch_invalid_ghosts(self):
1398         repos_url = self.make_client('d', 'dc')
1399         self.build_tree({'dc/bla': "data"})
1400         self.client_add("dc/bla")
1401         self.client_set_prop("dc", "bzr:ancestry:v3-none", "a ghost\n")
1402         self.client_commit("dc", "My Message")
1403         oldrepos = Repository.open("svn+"+repos_url)
1404         dir = BzrDir.create("f",format.get_rich_root_format())
1405         newrepos = dir.create_repository()
1406         oldrepos.copy_content_into(newrepos)
1407
1408         rev = newrepos.get_revision(oldrepos.generate_revision_id(1, "", "none"))
1409         self.assertEqual([oldrepos.generate_revision_id(0, "", "none")], rev.parent_ids)
1410
1411     def test_fetch_property_change_only(self):
1412         repos_url = self.make_client('d', 'dc')
1413         self.build_tree({'dc/trunk/bla': "data"})
1414         self.client_add("dc/trunk")
1415         self.client_commit("dc", "My Message") #1
1416         self.client_set_prop("dc", "some:property", "some data\n")
1417         self.client_update("dc")
1418         self.client_commit("dc", "My 3") #2
1419         self.client_set_prop("dc", "some2:property", "some data\n")
1420         self.client_commit("dc", "My 2") #3
1421         self.client_set_prop("dc", "some:property", "some data4\n")
1422         self.client_commit("dc", "My 4") #4
1423         oldrepos = Repository.open("svn+"+repos_url)
1424         dir = BzrDir.create("f", format.get_rich_root_format())
1425         newrepos = dir.create_repository()
1426         oldrepos.copy_content_into(newrepos)
1427         self.assertEquals([
1428             oldrepos.generate_revision_id(0, "", "none"),
1429             oldrepos.generate_revision_id(1, "", "none"),
1430             oldrepos.generate_revision_id(2, "", "none"),
1431             oldrepos.generate_revision_id(3, "", "none"),
1432             oldrepos.generate_revision_id(4, "", "none"),
1433             ], newrepos.all_revision_ids())
1434
1435     def test_fetch_property_change_only_trunk(self):
1436         repos_url = self.make_client('d', 'dc')
1437         self.build_tree({'dc/trunk/bla': "data"})
1438         self.client_add("dc/trunk")
1439         self.client_commit("dc", "My Message")
1440         self.client_set_prop("dc/trunk", "some:property", "some data\n")
1441         self.client_commit("dc", "My 3")
1442         self.client_set_prop("dc/trunk", "some2:property", "some data\n")
1443         self.client_commit("dc", "My 2")
1444         self.client_set_prop("dc/trunk", "some:property", "some data3\n")
1445         self.client_commit("dc", "My 4")
1446         oldrepos = Repository.open("svn+"+repos_url)
1447         oldrepos.set_branching_scheme(TrunkBranchingScheme())
1448         dir = BzrDir.create("f", format.get_rich_root_format())
1449         newrepos = dir.create_repository()
1450         oldrepos.copy_content_into(newrepos)
1451         self.assertEquals([
1452             oldrepos.generate_revision_id(1, "trunk", "trunk0"),
1453             oldrepos.generate_revision_id(2, "trunk", "trunk0"),
1454             oldrepos.generate_revision_id(3, "trunk", "trunk0"),
1455             oldrepos.generate_revision_id(4, "trunk", "trunk0"),
1456             ], newrepos.all_revision_ids())
1457
1458     def test_fetch_crosscopy(self):
1459         repos_url = self.make_client('d', 'dc')
1460         self.build_tree({'dc/trunk/adir/afile': "data", 
1461                          'dc/trunk/adir/stationary': None,
1462                          'dc/branches/abranch': None})
1463         self.client_add("dc/trunk")
1464         self.client_add("dc/branches")
1465         self.client_commit("dc", "Initial commit")
1466
1467         # copyrev
1468         self.client_copy("dc/trunk/adir", "dc/branches/abranch/bdir")
1469         self.client_commit("dc", "Cross copy commit")
1470
1471         # prevrev
1472         self.build_tree({"dc/branches/abranch/bdir/afile": "otherdata"})
1473         self.client_commit("dc", "Change data")
1474
1475         # lastrev
1476         self.build_tree({"dc/branches/abranch/bdir/bfile": "camel",
1477                       "dc/branches/abranch/bdir/stationary/traveller": "data"})
1478         self.client_add("dc/branches/abranch/bdir/bfile")
1479         self.client_add("dc/branches/abranch/bdir/stationary/traveller")
1480         self.client_commit("dc", "Change dir")
1481
1482         oldrepos = Repository.open("svn+"+repos_url)
1483         oldrepos.set_branching_scheme(TrunkBranchingScheme())
1484         dir = BzrDir.create("f",format.get_rich_root_format())
1485         newrepos = dir.create_repository()
1486         copyrev = oldrepos.generate_revision_id(2, "branches/abranch", "trunk0")
1487         prevrev = oldrepos.generate_revision_id(3, "branches/abranch", "trunk0")
1488         lastrev = oldrepos.generate_revision_id(4, "branches/abranch", "trunk0")
1489         oldrepos.copy_content_into(newrepos, lastrev)
1490
1491         inventory = newrepos.get_inventory(lastrev)
1492         self.assertEqual(prevrev, 
1493                          inventory[inventory.path2id("bdir/afile")].revision)
1494
1495         inventory = newrepos.get_inventory(prevrev)
1496         self.assertEqual(copyrev, 
1497                          inventory[inventory.path2id("bdir/stationary")].revision)
1498
1499