146
146
branch = self.make_branch('branch', format=knit2_format)
147
147
branch.pull(tree.branch, stop_revision='rev1')
148
148
repo = branch.repository
149
root_knit = repo.weave_store.get_weave('tree-root',
150
repo.get_transaction())
151
# Make sure fetch retrieved only what we requested
152
self.assertTrue('rev1' in root_knit)
153
self.assertTrue('rev2' not in root_knit)
151
# Make sure fetch retrieved only what we requested
152
self.assertEqual({('tree-root', 'rev1'):()},
153
repo.texts.get_parent_map(
154
[('tree-root', 'rev1'), ('tree-root', 'rev2')]))
154
157
branch.pull(tree.branch)
155
root_knit = repo.weave_store.get_weave('tree-root',
156
repo.get_transaction())
157
158
# Make sure that the next revision in the root knit was retrieved,
158
159
# even though the text, name, parent_id, etc., were unchanged.
159
self.assertTrue('rev2' in root_knit)
162
# Make sure fetch retrieved only what we requested
163
self.assertEqual({('tree-root', 'rev2'):(('tree-root', 'rev1'),)},
164
repo.texts.get_parent_map([('tree-root', 'rev2')]))
161
168
def test_fetch_incompatible(self):
162
169
knit_tree = self.make_branch_and_tree('knit', format='knit')
287
294
self.assertEqual(1, self._count_log_matches('/ce/id.kndx', http_logs))
288
295
self.assertEqual(1, self._count_log_matches('/ce/id.knit', http_logs))
289
# XXX: This *should* be '1', but more intrusive fetch changes are
290
# needed to drop this back to 1.
291
self.assertEqual(2, self._count_log_matches('inventory.kndx', http_logs))
296
self.assertEqual(1, self._count_log_matches('inventory.kndx', http_logs))
292
297
# this r-h check test will prevent regressions, but it currently already
293
298
# passes, before the patch to cache-rh is applied :[
294
299
self.assertTrue(1 >= self._count_log_matches('revision-history',
350
355
self.do_fetch_order_test('B', 'A')
352
357
def get_parents(self, file_id, revision_id):
353
transaction = self.repo.get_transaction()
354
vf = self.repo.weave_store.get_weave(file_id, transaction)
355
return vf.get_parents_with_ghosts(revision_id)
358
self.repo.lock_read()
360
parent_map = self.repo.texts.get_parent_map([(file_id, revision_id)])
361
return parent_map[(file_id, revision_id)]
357
365
def test_fetch_ghosts(self):
358
366
self.make_tree_and_repo()
366
374
self.tree.commit('second commit', rev_id='second-id')
367
375
self.repo.fetch(self.tree.branch.repository, 'second-id')
368
376
root_id = self.tree.get_root_id()
369
self.assertEqual(['left-parent', 'ghost-parent', 'not-ghost-parent'],
370
self.get_parents(root_id, 'second-id'))
378
((root_id, 'left-parent'), (root_id, 'ghost-parent'),
379
(root_id, 'not-ghost-parent')),
380
self.get_parents(root_id, 'second-id'))
372
382
def make_two_commits(self, change_root, fetch_twice):
373
383
self.make_tree_and_repo()
382
392
def test_fetch_changed_root(self):
383
393
self.make_two_commits(change_root=True, fetch_twice=False)
384
self.assertEqual([], self.get_parents('unique-id', 'second-id'))
394
self.assertEqual((), self.get_parents('unique-id', 'second-id'))
386
396
def test_two_fetch_changed_root(self):
387
397
self.make_two_commits(change_root=True, fetch_twice=True)
388
self.assertEqual([], self.get_parents('unique-id', 'second-id'))
398
self.assertEqual((), self.get_parents('unique-id', 'second-id'))
390
400
def test_two_fetches(self):
391
401
self.make_two_commits(change_root=False, fetch_twice=True)
392
self.assertEqual(['first-id'],
393
self.get_parents('TREE_ROOT', 'second-id'))
402
self.assertEqual((('TREE_ROOT', 'first-id'),),
403
self.get_parents('TREE_ROOT', 'second-id'))