28
28
gp = LogGraphProvider(False)
29
29
gp.open_branch(tree.branch, tree=tree)
31
self.assertEqual([(tree,
31
self.assertLength(1, gp.branches)
33
self.assertEqual(tree, bi.tree)
34
self.assertEqual(tree.branch, bi.branch)
35
self.assertEqual(None, bi.index)
35
37
self.assertLength(1, gp.repos)
36
38
self.assertEqual({tree.branch.repository.base: tree.branch.repository},
43
45
# If we don't pass the tree, it should open it.
44
46
gp.open_branch(tree.branch)
46
opened_tree = gp.branches()[0][0]
47
self.assertEqual(tree.basedir,
48
self.assertEqual(tree.basedir, gp.branches[0].tree.basedir)
50
50
def test_open_branch_without_tree(self):
51
51
branch = self.make_branch("branch")
53
53
gp = LogGraphProvider(False)
54
# If we don't pass the tree, it should open it.
55
55
gp.open_branch(branch)
57
self.assertEqual([(None, branch, None)],
58
self.assertEqual(None, bi.tree)
59
self.assertEqual(branch, bi.branch)
60
self.assertEqual(None, bi.index)
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)
72
gp.open_branch(branch, tree=tree, file_ids=['file1-id'])
73
self.assertEqual([(tree,
74
gp.open_branch(branch, tree=tree, file_ids = ['file1-id'])
75
self.assertLength(1, gp.branches)
77
self.assertEqual(tree, bi.tree)
78
self.assertEqual(branch, bi.branch)
79
self.assertEqual(None, bi.index)
77
81
self.assertEqual(['file1-id'], gp.fileids)
78
82
self.assertFalse(gp.has_dir)
80
gp.open_branch(branch, tree=tree, file_ids=['dir-id'])
81
self.assertEqual([(tree,
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)
88
gp.open_branch(branch, tree=tree, file_ids=['file3-id'])
89
self.assertEqual([(tree,
88
# Check that a new branch has not been added.
89
self.assertLength(1, gp.branches)
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)
95
# Check that a new branch has not been added.
96
self.assertLength(1, gp.branches)
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)
106
108
def branches_to_base(self, branches):
107
for tree, branch, index in branches:
109
yield (None, branch.base, index)
111
yield (None, bi.branch.base, bi.index)
111
yield (tree.basedir, branch.base, index)
113
yield (bi.tree.basedir, bi.branch.base, bi.index)
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"])
120
branches = gp.branches()
122
branches = gp.branches
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)))
126
128
self.assertLength(2, gp.repos)
127
129
self.assertEqual(branch1.repository.base,
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)))
150
152
def test_open_locations_raise_not_a_branch(self):
151
153
repo = self.make_repository("repo", shared=True)