~qbzr-dev/qbzr/show-merge-depth

« back to all changes in this revision

Viewing changes to lib/tests/test_loggraphprovider.py

  • Committer: Gary van der Merwe
  • Date: 2009-08-19 12:41:14 UTC
  • mfrom: (677.1.243 trunk)
  • Revision ID: garyvdm@gmail.com-20090819124114-jz8zf4o4dlcl0a4r
Merge Trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
        gp = LogGraphProvider(False)
29
29
        gp.open_branch(tree.branch, tree=tree)
30
30
        
31
 
        self.assertEqual([(tree,
32
 
                          tree.branch,
33
 
                          None)],
34
 
                         gp.branches())
 
31
        self.assertLength(1, gp.branches)
 
32
        bi = gp.branches[0]
 
33
        self.assertEqual(tree, bi.tree)
 
34
        self.assertEqual(tree.branch, bi.branch)
 
35
        self.assertEqual(None, bi.index)
 
36
        
35
37
        self.assertLength(1, gp.repos)
36
38
        self.assertEqual({tree.branch.repository.base: tree.branch.repository},
37
39
                         gp.repos)
43
45
        # If we don't pass the tree, it should open it.
44
46
        gp.open_branch(tree.branch)
45
47
        
46
 
        opened_tree = gp.branches()[0][0]
47
 
        self.assertEqual(tree.basedir,
48
 
                         opened_tree.basedir)
 
48
        self.assertEqual(tree.basedir, gp.branches[0].tree.basedir)
49
49
 
50
50
    def test_open_branch_without_tree(self):
51
51
        branch = self.make_branch("branch")
52
52
        
53
53
        gp = LogGraphProvider(False)
54
 
        # If we don't pass the tree, it should open it.
 
54
        
55
55
        gp.open_branch(branch)
56
56
        
57
 
        self.assertEqual([(None, branch, None)],
58
 
                         gp.branches())
 
57
        bi = gp.branches[0]
 
58
        self.assertEqual(None, bi.tree)
 
59
        self.assertEqual(branch, bi.branch)
 
60
        self.assertEqual(None, bi.index)
59
61
 
60
62
    def make_branch_and_tree_with_files_and_dir(self):
61
63
        tree = self.make_branch_and_tree("branch")
69
71
    def check_open_branch_files(self, tree, branch):
70
72
        gp = LogGraphProvider(False)
71
73
        
72
 
        gp.open_branch(branch, tree=tree, file_ids=['file1-id'])
73
 
        self.assertEqual([(tree,
74
 
                          branch,
75
 
                          None)],
76
 
                         gp.branches())
 
74
        gp.open_branch(branch, tree=tree, file_ids = ['file1-id'])
 
75
        self.assertLength(1, gp.branches)
 
76
        bi = gp.branches[0]
 
77
        self.assertEqual(tree, bi.tree)
 
78
        self.assertEqual(branch, bi.branch)
 
79
        self.assertEqual(None, bi.index)
 
80
 
77
81
        self.assertEqual(['file1-id'], gp.fileids)
78
82
        self.assertFalse(gp.has_dir)
79
83
        
80
 
        gp.open_branch(branch, tree=tree, file_ids=['dir-id'])
81
 
        self.assertEqual([(tree,
82
 
                          branch,
83
 
                          None)],
84
 
                         gp.branches())
 
84
        gp.open_branch(branch, tree=tree, file_ids = ['dir-id'])        
85
85
        self.assertEqual(['file1-id', 'dir-id'], gp.fileids)
86
86
        self.assertTrue(gp.has_dir)
87
87
        
88
 
        gp.open_branch(branch, tree=tree, file_ids=['file3-id'])
89
 
        self.assertEqual([(tree,
90
 
                          branch,
91
 
                          None)],
92
 
                         gp.branches())
 
88
        # Check that a new branch has not been added.
 
89
        self.assertLength(1, gp.branches)
 
90
        
 
91
        gp.open_branch(branch, tree=tree, file_ids = ['file3-id'])
93
92
        self.assertEqual(['file1-id', 'dir-id','file3-id'], gp.fileids)
94
93
        self.assertTrue(gp.has_dir)
 
94
        
 
95
        # Check that a new branch has not been added.
 
96
        self.assertLength(1, gp.branches)
95
97
    
96
98
    def test_open_branch_files(self):
97
99
        tree = self.make_branch_and_tree_with_files_and_dir()
104
106
        self.check_open_branch_files(None, branch)
105
107
    
106
108
    def branches_to_base(self, branches):
107
 
        for tree, branch, index in branches:
108
 
            if tree is None:
109
 
                yield (None, branch.base, index)
 
109
        for bi in branches:
 
110
            if  bi.tree is None:
 
111
                yield (None, bi.branch.base, bi.index)
110
112
            else:
111
 
                yield (tree.basedir, branch.base, index)
 
113
                yield (bi.tree.basedir, bi.branch.base, bi.index)
112
114
    
113
115
    def test_open_locations_standalone_branches(self):
114
116
        branch1 = self.make_branch("branch1")
117
119
        gp = LogGraphProvider(False)
118
120
        gp.open_locations(["branch1", "branch2"])
119
121
        
120
 
        branches = gp.branches()
 
122
        branches = gp.branches
121
123
        
122
124
        self.assertEqual(set(((None,          branch1.base, None),
123
125
                              (tree2.basedir, tree2.branch.base, None) )),
124
 
                         set(self.branches_to_base(gp.branches())))
 
126
                         set(self.branches_to_base(gp.branches)))
125
127
        
126
128
        self.assertLength(2, gp.repos)
127
129
        self.assertEqual(branch1.repository.base,
145
147
        
146
148
        self.assertEqual(set(((None, branch1.base, None),
147
149
                          (tree2.basedir, tree2.branch.base, None))),
148
 
                         set(self.branches_to_base(gp.branches())))
 
150
                         set(self.branches_to_base(gp.branches)))
149
151
    
150
152
    def test_open_locations_raise_not_a_branch(self):
151
153
        repo = self.make_repository("repo", shared=True)