93
80
self.assertEquals(set(["a", "b"]),
94
81
self._find_missing({"a": ["b"], "b": ["c"], "c": ["d"]},
98
class LRUTreeCacheTests(TestCaseWithTransport):
101
super(LRUTreeCacheTests, self).setUp()
102
self.branch = self.make_branch(".")
103
self.branch.lock_write()
104
self.addCleanup(self.branch.unlock)
105
self.cache = LRUTreeCache(self.branch.repository)
107
def test_get_not_present(self):
108
self.assertRaises(NoSuchRevision, self.cache.revision_tree,
111
def test_revision_trees(self):
112
self.assertRaises(NoSuchRevision, self.cache.revision_trees,
115
def test_iter_revision_trees(self):
116
self.assertRaises(NoSuchRevision, self.cache.iter_revision_trees,
120
bb = BranchBuilder(branch=self.branch)
122
bb.build_snapshot('BASE-id', None,
123
[('add', ('', None, 'directory', None)),
124
('add', ('foo', 'foo-id', 'file', 'a\nb\nc\nd\ne\n')),
127
tree = self.cache.revision_tree("BASE-id")
128
self.assertEquals("BASE-id", tree.get_revision_id())
131
class BazaarObjectStoreTests(TestCaseWithTransport):
134
super(BazaarObjectStoreTests, self).setUp()
135
self.branch = self.make_branch(".")
136
self.branch.lock_write()
137
self.addCleanup(self.branch.unlock)
138
self.store = BazaarObjectStore(self.branch.repository)
140
def test_get_blob(self):
142
b.data = 'a\nb\nc\nd\ne\n'
143
self.assertRaises(KeyError, self.store.__getitem__, b.id)
144
bb = BranchBuilder(branch=self.branch)
146
bb.build_snapshot('BASE-id', None,
147
[('add', ('', None, 'directory', None)),
148
('add', ('foo', 'foo-id', 'file', 'a\nb\nc\nd\ne\n')),
151
self.assertEquals(b, self.store[b.id])
153
def test_get_raw(self):
155
b.data = 'a\nb\nc\nd\ne\n'
156
self.assertRaises(KeyError, self.store.get_raw, b.id)
157
bb = BranchBuilder(branch=self.branch)
159
bb.build_snapshot('BASE-id', None,
160
[('add', ('', None, 'directory', None)),
161
('add', ('foo', 'foo-id', 'file', 'a\nb\nc\nd\ne\n')),
164
self.assertEquals(b.as_raw_string(), self.store.get_raw(b.id)[1])
166
def test_contains(self):
168
b.data = 'a\nb\nc\nd\ne\n'
169
self.assertFalse(b.id in self.store)
170
bb = BranchBuilder(branch=self.branch)
172
bb.build_snapshot('BASE-id', None,
173
[('add', ('', None, 'directory', None)),
174
('add', ('foo', 'foo-id', 'file', 'a\nb\nc\nd\ne\n')),
177
self.assertTrue(b.id in self.store)
180
class TreeToObjectsTests(TestCaseWithTransport):
183
super(TreeToObjectsTests, self).setUp()
184
self.idmap = DictGitShaMap()
186
def test_no_changes(self):
187
tree = self.make_branch_and_tree('.')
188
entries = list(_tree_to_objects(tree, [tree], self.idmap, {}))
189
self.assertEquals([], entries)