~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_memorytree.py

  • Committer: Andrew Bennetts
  • Date: 2008-08-07 00:25:38 UTC
  • mfrom: (3612 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3613.
  • Revision ID: andrew.bennetts@canonical.com-20080807002538-mtl1fcgy2fdabha4
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
125
125
        self.assertEqual('barshoom', tree.get_file('foo-id').read())
126
126
        tree.unlock()
127
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
 
128
144
    def test_commit_trivial(self):
129
145
        """Smoke test for commit on a MemoryTree.
130
146