~ubuntu-branches/ubuntu/karmic/bzr/karmic-proposed

« back to all changes in this revision

Viewing changes to bzrlib/tests/repository_implementations/test_commit_builder.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2008-08-25 19:06:49 UTC
  • mfrom: (1.1.44 upstream)
  • Revision ID: james.westby@ubuntu.com-20080825190649-pq87jonr4uvs7s0y
Tags: 1.6-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    repository,
29
29
    tests,
30
30
    )
 
31
from bzrlib.graph import Graph
31
32
from bzrlib.tests.repository_implementations import test_repository
32
33
 
33
34
 
243
244
        tree1, tree2 = self._get_revtrees(tree, [rev1, rev2])
244
245
        self.assertEqual(rev1, tree1.inventory[name + 'id'].revision)
245
246
        self.assertEqual(rev1, tree2.inventory[name + 'id'].revision)
246
 
        self.assertFileAncestry([rev1], tree, name)
 
247
        file_id = name + 'id'
 
248
        expected_graph = {}
 
249
        expected_graph[(file_id, rev1)] = ()
 
250
        self.assertFileGraph(expected_graph, tree, (file_id, rev1))
247
251
 
248
252
    def test_last_modified_revision_after_commit_dir_unchanged(self):
249
253
        # committing without changing a dir does not change the last modified.
264
268
        tree1, tree2 = self._get_revtrees(tree, [rev1, rev2])
265
269
        self.assertEqual(rev1, tree1.inventory['dirid'].revision)
266
270
        self.assertEqual(rev1, tree2.inventory['dirid'].revision)
267
 
        self.assertFileAncestry([rev1], tree, 'dir')
 
271
        file_id = 'dirid'
 
272
        expected_graph = {}
 
273
        expected_graph[(file_id, rev1)] = ()
 
274
        self.assertFileGraph(expected_graph, tree, (file_id, rev1))
268
275
 
269
276
    def test_last_modified_revision_after_commit_file_unchanged(self):
270
277
        # committing without changing a file does not change the last modified.
337
344
        tree1, tree2 = self._get_revtrees(tree, [rev1, rev2])
338
345
        self.assertEqual(rev1, tree1.inventory[name + 'id'].revision)
339
346
        self.assertEqual(rev2, tree2.inventory[name + 'id'].revision)
340
 
        self.assertFileAncestry([rev1, rev2], tree, name)
 
347
        file_id = name + 'id'
 
348
        expected_graph = {}
 
349
        expected_graph[(file_id, rev1)] = ()
 
350
        expected_graph[(file_id, rev2)] = ((file_id, rev1),)
 
351
        self.assertFileGraph(expected_graph, tree, (file_id, rev2))
341
352
 
342
353
    def mini_commit(self, tree, name, new_name, records_version=True,
343
354
        delta_against_basis=True):
407
418
            tree.unlock()
408
419
        return rev2
409
420
 
410
 
    def assertFileAncestry(self, ancestry, tree, name, alt_ancestry=None):
 
421
    def assertFileGraph(self, expected_graph, tree, tip):
411
422
        # all the changes that have occured should be in the ancestry
412
423
        # (closest to a public per-file graph API we have today)
413
424
        tree.lock_read()
414
425
        self.addCleanup(tree.unlock)
415
 
        vw = tree.branch.repository.weave_store.get_weave(name + 'id',
416
 
            tree.branch.repository.get_transaction())
417
 
        result = vw.get_ancestry([ancestry[-1]])
418
 
        if alt_ancestry is None:
419
 
            self.assertEqual(ancestry, result)
420
 
        else:
421
 
            self.assertSubset([tuple(result)],
422
 
                [tuple(ancestry), tuple(alt_ancestry)])
 
426
        graph = dict(Graph(tree.branch.repository.texts).iter_ancestry([tip]))
 
427
        self.assertEqual(expected_graph, graph)
423
428
 
424
429
    def test_last_modified_revision_after_content_file_changes(self):
425
430
        # altering a file changes the last modified.
457
462
        rev4 = self.mini_commit(tree1, 'new_' + name, 'new_' + name)
458
463
        tree3, = self._get_revtrees(tree1, [rev4])
459
464
        self.assertEqual(rev4, tree3.inventory[name + 'id'].revision)
460
 
        # TODO: change this to an assertFileGraph call to check the
461
 
        # parent order of rev4: it should be rev2, rev3
462
 
        self.assertFileAncestry([rev1, rev2, rev3, rev4], tree1, name,
463
 
            [rev1, rev3, rev2, rev4])
 
465
        file_id = name + 'id'
 
466
        expected_graph = {}
 
467
        expected_graph[(file_id, rev1)] = ()
 
468
        expected_graph[(file_id, rev2)] = ((file_id, rev1),)
 
469
        expected_graph[(file_id, rev3)] = ((file_id, rev1),)
 
470
        expected_graph[(file_id, rev4)] = ((file_id, rev2), (file_id, rev3),)
 
471
        self.assertFileGraph(expected_graph, tree1, (file_id, rev4))
464
472
 
465
473
    def test_last_modified_revision_after_merge_dir_changes(self):
466
474
        # merge a dir changes the last modified.
489
497
        rev3 = self.mini_commit(tree1, name, 'new_' + name, False)
490
498
        tree3, = self._get_revtrees(tree1, [rev2])
491
499
        self.assertEqual(rev2, tree3.inventory[name + 'id'].revision)
492
 
        self.assertFileAncestry([rev1, rev2], tree1, name)
 
500
        file_id = name + 'id'
 
501
        expected_graph = {}
 
502
        expected_graph[(file_id, rev1)] = ()
 
503
        expected_graph[(file_id, rev2)] = ((file_id, rev1),)
 
504
        self.assertFileGraph(expected_graph, tree1, (file_id, rev2))
493
505
 
494
506
    def test_last_modified_revision_after_converged_merge_dir_changes(self):
495
507
        # merge a dir changes the last modified.