~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-08-15 03:18:20 UTC
  • mfrom: (1910.2.6 format-bumps)
  • Revision ID: pqm@pqm.ubuntu.com-20060815031820-fde63c7ba995e484
Root entry always has a revision id

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for repository commit builder."""
18
18
 
 
19
from bzrlib import inventory
19
20
from bzrlib.errors import UnsupportedOperation
20
21
from bzrlib.repository import CommitBuilder
21
22
from bzrlib.tests.repository_implementations.test_repository import TestCaseWithRepository
28
29
        builder = tree.branch.get_commit_builder([])
29
30
        self.assertIsInstance(builder, CommitBuilder)
30
31
 
 
32
    def record_root(self, builder, tree):
 
33
        if builder.record_root_entry is True:
 
34
            ie = tree.inventory.root
 
35
            parent_tree = tree.branch.repository.revision_tree(None)
 
36
            parent_invs = [parent_tree.inventory]
 
37
            builder.record_entry_contents(ie, parent_invs, '', tree)
 
38
 
31
39
    def test_finish_inventory(self):
32
40
        tree = self.make_branch_and_tree(".")
33
41
        builder = tree.branch.get_commit_builder([])
 
42
        self.record_root(builder, tree)
34
43
        builder.finish_inventory()
35
44
 
36
45
    def test_commit_message(self):
37
46
        tree = self.make_branch_and_tree(".")
38
47
        builder = tree.branch.get_commit_builder([])
 
48
        self.record_root(builder, tree)
39
49
        builder.finish_inventory()
40
50
        rev_id = builder.commit('foo bar blah')
41
51
        rev = tree.branch.repository.get_revision(rev_id)
48
58
        except UnsupportedOperation:
49
59
            # This format doesn't support supplied revision ids
50
60
            return
 
61
        self.record_root(builder, tree)
51
62
        builder.finish_inventory()
52
63
        self.assertEqual("foo", builder.commit('foo bar'))
53
64
        self.assertTrue(tree.branch.repository.has_revision("foo"))
59
70
    def test_commit(self):
60
71
        tree = self.make_branch_and_tree(".")
61
72
        builder = tree.branch.get_commit_builder([])
 
73
        self.record_root(builder, tree)
62
74
        builder.finish_inventory()
63
75
        rev_id = builder.commit('foo bar')
64
76
        self.assertNotEqual(None, rev_id)