~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-10-15 16:32:29 UTC
  • mfrom: (1731.1.67 unique-root)
  • Revision ID: pqm@pqm.ubuntu.com-20061015163229-648b1f2ebe692136
New trees have unique root ids

Show diffs side-by-side

added added

removed removed

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