~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Aaron Bentley
  • Date: 2007-02-06 14:52:16 UTC
  • mfrom: (2266 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2268.
  • Revision ID: abentley@panoramicfeedback.com-20070206145216-fcpi8o3ufvuzwbp9
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import sys
20
20
 
21
21
from bzrlib import (
 
22
    errors,
 
23
    generate_ids,
22
24
    tests,
23
25
    urlutils,
24
26
    )
47
49
    def get_transform(self):
48
50
        transform = TreeTransform(self.wt)
49
51
        #self.addCleanup(transform.finalize)
50
 
        return transform, transform.trans_id_tree_file_id(self.wt.get_root_id())
 
52
        return transform, transform.root
51
53
 
52
54
    def test_existing_limbo(self):
53
55
        limbo_name = urlutils.local_path_from_url(
197
199
        transform3.delete_contents(oz_id)
198
200
        self.assertEqual(transform3.find_conflicts(), 
199
201
                         [('missing parent', oz_id)])
200
 
        root_id = transform3.trans_id_tree_file_id('TREE_ROOT')
 
202
        root_id = transform3.root
201
203
        tip_id = transform3.trans_id_tree_file_id('tip-id')
202
204
        transform3.adjust_path('tip', root_id, tip_id)
203
205
        transform3.apply()
229
231
    def test_name_invariants(self):
230
232
        create_tree, root = self.get_transform()
231
233
        # prepare tree
232
 
        root = create_tree.trans_id_tree_file_id('TREE_ROOT')
 
234
        root = create_tree.root
233
235
        create_tree.new_file('name1', root, 'hello1', 'name1')
234
236
        create_tree.new_file('name2', root, 'hello2', 'name2')
235
237
        ddir = create_tree.new_directory('dying_directory', root, 'ddir')
239
241
        create_tree.apply()
240
242
 
241
243
        mangle_tree,root = self.get_transform()
242
 
        root = mangle_tree.trans_id_tree_file_id('TREE_ROOT')
 
244
        root = mangle_tree.root
243
245
        #swap names
244
246
        name1 = mangle_tree.trans_id_tree_file_id('name1')
245
247
        name2 = mangle_tree.trans_id_tree_file_id('name2')
324
326
    def test_move_dangling_ie(self):
325
327
        create_tree, root = self.get_transform()
326
328
        # prepare tree
327
 
        root = create_tree.trans_id_tree_file_id('TREE_ROOT')
 
329
        root = create_tree.root
328
330
        create_tree.new_file('name1', root, 'hello1', 'name1')
329
331
        create_tree.apply()
330
332
        delete_contents, root = self.get_transform()
340
342
    def test_replace_dangling_ie(self):
341
343
        create_tree, root = self.get_transform()
342
344
        # prepare tree
343
 
        root = create_tree.trans_id_tree_file_id('TREE_ROOT')
 
345
        root = create_tree.root
344
346
        create_tree.new_file('name1', root, 'hello1', 'name1')
345
347
        create_tree.apply()
346
348
        delete_contents = TreeTransform(self.wt)
587
589
 
588
590
 
589
591
class TransformGroup(object):
590
 
    def __init__(self, dirname):
 
592
    def __init__(self, dirname, root_id):
591
593
        self.name = dirname
592
594
        os.mkdir(dirname)
593
595
        self.wt = BzrDir.create_standalone_workingtree(dirname)
 
596
        self.wt.set_root_id(root_id)
594
597
        self.b = self.wt.branch
595
598
        self.tt = TreeTransform(self.wt)
596
599
        self.root = self.tt.trans_id_tree_file_id(self.wt.get_root_id())
602
605
 
603
606
class TestTransformMerge(TestCaseInTempDir):
604
607
    def test_text_merge(self):
605
 
        base = TransformGroup("base")
 
608
        root_id = generate_ids.gen_root_id()
 
609
        base = TransformGroup("base", root_id)
606
610
        base.tt.new_file('a', base.root, 'a\nb\nc\nd\be\n', 'a')
607
611
        base.tt.new_file('b', base.root, 'b1', 'b')
608
612
        base.tt.new_file('c', base.root, 'c', 'c')
612
616
        base.tt.new_directory('g', base.root, 'g')
613
617
        base.tt.new_directory('h', base.root, 'h')
614
618
        base.tt.apply()
615
 
        other = TransformGroup("other")
 
619
        other = TransformGroup("other", root_id)
616
620
        other.tt.new_file('a', other.root, 'y\nb\nc\nd\be\n', 'a')
617
621
        other.tt.new_file('b', other.root, 'b2', 'b')
618
622
        other.tt.new_file('c', other.root, 'c2', 'c')
623
627
        other.tt.new_file('h', other.root, 'h\ni\nj\nk\n', 'h')
624
628
        other.tt.new_file('i', other.root, 'h\ni\nj\nk\n', 'i')
625
629
        other.tt.apply()
626
 
        this = TransformGroup("this")
 
630
        this = TransformGroup("this", root_id)
627
631
        this.tt.new_file('a', this.root, 'a\nb\nc\nd\bz\n', 'a')
628
632
        this.tt.new_file('b', this.root, 'b', 'b')
629
633
        this.tt.new_file('c', this.root, 'c', 'c')
680
684
    def test_file_merge(self):
681
685
        if not has_symlinks():
682
686
            raise TestSkipped('Symlinks are not supported on this platform')
683
 
        base = TransformGroup("BASE")
684
 
        this = TransformGroup("THIS")
685
 
        other = TransformGroup("OTHER")
 
687
        root_id = generate_ids.gen_root_id()
 
688
        base = TransformGroup("BASE", root_id)
 
689
        this = TransformGroup("THIS", root_id)
 
690
        other = TransformGroup("OTHER", root_id)
686
691
        for tg in this, base, other:
687
692
            tg.tt.new_directory('a', tg.root, 'a')
688
693
            tg.tt.new_symlink('b', tg.root, 'b', 'b')
720
725
        self.assertIs(os.path.lexists(this.wt.abspath('h.OTHER')), True)
721
726
 
722
727
    def test_filename_merge(self):
723
 
        base = TransformGroup("BASE")
724
 
        this = TransformGroup("THIS")
725
 
        other = TransformGroup("OTHER")
 
728
        root_id = generate_ids.gen_root_id()
 
729
        base = TransformGroup("BASE", root_id)
 
730
        this = TransformGroup("THIS", root_id)
 
731
        other = TransformGroup("OTHER", root_id)
726
732
        base_a, this_a, other_a = [t.tt.new_directory('a', t.root, 'a') 
727
733
                                   for t in [base, this, other]]
728
734
        base_b, this_b, other_b = [t.tt.new_directory('b', t.root, 'b') 
752
758
        self.assertEqual(this.wt.id2path('f'), pathjoin('b/f1'))
753
759
 
754
760
    def test_filename_merge_conflicts(self):
755
 
        base = TransformGroup("BASE")
756
 
        this = TransformGroup("THIS")
757
 
        other = TransformGroup("OTHER")
 
761
        root_id = generate_ids.gen_root_id()
 
762
        base = TransformGroup("BASE", root_id)
 
763
        this = TransformGroup("THIS", root_id)
 
764
        other = TransformGroup("OTHER", root_id)
758
765
        base_a, this_a, other_a = [t.tt.new_directory('a', t.root, 'a') 
759
766
                                   for t in [base, this, other]]
760
767
        base_b, this_b, other_b = [t.tt.new_directory('b', t.root, 'b') 
904
911
        target = self.make_branch_and_tree('target')
905
912
        self.build_tree(['target/name'])
906
913
        target.add('name')
907
 
        self.assertRaises(AssertionError, build_tree, source.basis_tree(),
908
 
                          target)
 
914
        self.assertRaises(errors.WorkingTreeAlreadyPopulated, 
 
915
            build_tree, source.basis_tree(), target)
909
916
 
910
917
 
911
918
class MockTransform(object):