~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_memorytree.py

  • Committer: John Arbash Meinel
  • Author(s): Mark Hammond
  • Date: 2008-09-09 17:02:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3697.
  • Revision ID: john@arbash-meinel.com-20080909170221-svim3jw2mrz0amp3
An updated transparent icon for bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
            tree.get_file(tree.path2id('foo')).read())
53
53
        tree.unlock()
54
54
 
 
55
    def test_get_root_id(self):
 
56
        branch = self.make_branch('branch')
 
57
        tree = MemoryTree.create_on_branch(branch)
 
58
        tree.lock_write()
 
59
        try:
 
60
            tree.add([''])
 
61
            self.assertIsNot(None, tree.get_root_id())
 
62
        finally:
 
63
            tree.unlock()
 
64
 
55
65
    def test_lock_tree_write(self):
56
66
        """Check we can lock_tree_write and unlock MemoryTrees."""
57
67
        branch = self.make_branch('branch')
115
125
        self.assertEqual('barshoom', tree.get_file('foo-id').read())
116
126
        tree.unlock()
117
127
 
 
128
    def test_add_in_subdir(self):
 
129
        branch = self.make_branch('branch')
 
130
        tree = MemoryTree.create_on_branch(branch)
 
131
        tree.lock_write()
 
132
        self.addCleanup(tree.unlock)
 
133
        tree.add([''], ['root-id'], ['directory'])
 
134
        # Unfortunately, the only way to 'mkdir' is to call 'tree.mkdir', but
 
135
        # that *always* adds the directory as well. So if you want to create a
 
136
        # file in a subdirectory, you have to split out the 'mkdir()' calls
 
137
        # from the add and put_file_bytes_non_atomic calls. :(
 
138
        tree.mkdir('adir', 'dir-id')
 
139
        tree.add(['adir/afile'], ['file-id'], ['file'])
 
140
        self.assertEqual('adir/afile', tree.id2path('file-id'))
 
141
        self.assertEqual('adir', tree.id2path('dir-id'))
 
142
        tree.put_file_bytes_non_atomic('file-id', 'barshoom')
 
143
 
118
144
    def test_commit_trivial(self):
119
145
        """Smoke test for commit on a MemoryTree.
120
146
 
133
159
        tree.unlock()
134
160
        # and we should have a revision that is accessible outside the tree lock
135
161
        revtree = tree.branch.repository.revision_tree(revision_id)
 
162
        revtree.lock_read()
 
163
        self.addCleanup(revtree.unlock)
136
164
        self.assertEqual('barshoom', revtree.get_file('foo-id').read())
137
165
 
138
166
    def test_unversion(self):