/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_memorytree.py

Merge bzr.dev, resolve conflicts.

Check failing tests:

- bug #225020 is back under a different ugly head. But I don't think it's
  worth working around it *again* given that: it's a bug in curl and
  fixed there (in 7.19, still need checking for 7.18.2 available in
  intrepid), occurs only in the test suite and only with
  python-2.7.0alpha0, I need a true python-2.6 (wip).

- more problematic are the thread leaks, it seems that python-2.6 refuse
  to spawn more than 256 and the whole test suite hits that
  limit. Re-running failing tests with --starting-with succeeds.

- some test_read_bundle tests fail with a curl connection error (server
  certificate verification failed) but they use the wrong CAfile (need
  investigaton, most probably a wrong setUp, we need to use a CAfile that
  knows about the test server).

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
 
166
182
        rev_id = tree.commit('first post')
167
183
        tree.unlock()
168
184
        self.assertEqual(rev_id, tree.last_revision())
 
185
 
 
186
    def test_rename_file(self):
 
187
        tree = self.make_branch_and_memory_tree('branch')
 
188
        tree.lock_write()
 
189
        self.addCleanup(tree.unlock)
 
190
        tree.add(['', 'foo'], ['root-id', 'foo-id'], ['directory', 'file'])
 
191
        tree.put_file_bytes_non_atomic('foo-id', 'content\n')
 
192
        tree.commit('one', rev_id='rev-one')
 
193
        tree.rename_one('foo', 'bar')
 
194
        self.assertEqual('bar', tree.id2path('foo-id'))
 
195
        self.assertEqual('content\n', tree._file_transport.get_bytes('bar'))
 
196
        self.assertRaises(errors.NoSuchFile,
 
197
                          tree._file_transport.get_bytes, 'foo')
 
198
        tree.commit('two', rev_id='rev-two')
 
199
        self.assertEqual('content\n', tree._file_transport.get_bytes('bar'))
 
200
        self.assertRaises(errors.NoSuchFile,
 
201
                          tree._file_transport.get_bytes, 'foo')
 
202
 
 
203
        rev_tree2 = tree.branch.repository.revision_tree('rev-two')
 
204
        self.assertEqual('bar', rev_tree2.id2path('foo-id'))
 
205
        self.assertEqual('content\n', rev_tree2.get_file_text('foo-id'))
 
206
 
 
207
    def test_rename_file_to_subdir(self):
 
208
        tree = self.make_branch_and_memory_tree('branch')
 
209
        tree.lock_write()
 
210
        self.addCleanup(tree.unlock)
 
211
        tree.add('')
 
212
        tree.mkdir('subdir', 'subdir-id')
 
213
        tree.add('foo', 'foo-id', 'file')
 
214
        tree.put_file_bytes_non_atomic('foo-id', 'content\n')
 
215
        tree.commit('one', rev_id='rev-one')
 
216
 
 
217
        tree.rename_one('foo', 'subdir/bar')
 
218
        self.assertEqual('subdir/bar', tree.id2path('foo-id'))
 
219
        self.assertEqual('content\n',
 
220
                         tree._file_transport.get_bytes('subdir/bar'))
 
221
        tree.commit('two', rev_id='rev-two')
 
222
        rev_tree2 = tree.branch.repository.revision_tree('rev-two')
 
223
        self.assertEqual('subdir/bar', rev_tree2.id2path('foo-id'))