~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_memorytree.py

  • Committer: Andrew Bennetts
  • Date: 2007-03-26 06:24:01 UTC
  • mto: This revision was merged to the branch mainline in revision 2376.
  • Revision ID: andrew.bennetts@canonical.com-20070326062401-k3nbefzje5332jaf
Deal with review comments from Robert:

  * Add my name to the NEWS file
  * Move the test case to a new module in branch_implementations
  * Remove revision_history cruft from identitymap and test_identitymap
  * Improve some docstrings

Also, this fixes a bug where revision_history was not returning a copy of the
cached data, allowing the cache to be corrupted.

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
 
 
65
55
    def test_lock_tree_write(self):
66
56
        """Check we can lock_tree_write and unlock MemoryTrees."""
67
57
        branch = self.make_branch('branch')
125
115
        self.assertEqual('barshoom', tree.get_file('foo-id').read())
126
116
        tree.unlock()
127
117
 
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
 
 
144
118
    def test_commit_trivial(self):
145
119
        """Smoke test for commit on a MemoryTree.
146
120
 
159
133
        tree.unlock()
160
134
        # and we should have a revision that is accessible outside the tree lock
161
135
        revtree = tree.branch.repository.revision_tree(revision_id)
162
 
        revtree.lock_read()
163
 
        self.addCleanup(revtree.unlock)
164
136
        self.assertEqual('barshoom', revtree.get_file('foo-id').read())
165
137
 
166
138
    def test_unversion(self):