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