/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/tree_implementations/test_tree.py

  • Committer: Aaron Bentley
  • Date: 2008-10-12 16:11:17 UTC
  • mfrom: (3774 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3775.
  • Revision ID: aaron@aaronbentley.com-20081012161117-et0n1u2221zzwc8z
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from bzrlib import (
18
18
    errors,
 
19
    conflicts,
 
20
    osutils,
 
21
    revisiontree,
19
22
    tests,
20
 
    conflicts,
 
23
    workingtree_4,
21
24
    )
22
25
from bzrlib.tests import TestSkipped
23
26
from bzrlib.tests.tree_implementations import TestCaseWithTree
216
219
        self.addCleanup(tree.unlock)
217
220
        self.assertTrue(tree.has_id('file-id'))
218
221
        self.assertFalse(tree.has_id('dir-id'))
 
222
 
 
223
    def test___contains__(self):
 
224
        work_tree = self.make_branch_and_tree('tree')
 
225
        self.build_tree(['tree/file'])
 
226
        work_tree.add('file', 'file-id')
 
227
        tree = self._convert_tree(work_tree)
 
228
        tree.lock_read()
 
229
        self.addCleanup(tree.unlock)
 
230
        self.assertTrue('file-id' in tree)
 
231
        self.assertFalse('dir-id' in tree)
 
232
 
 
233
 
 
234
class TestExtras(TestCaseWithTree):
 
235
 
 
236
    def test_extras(self):
 
237
        work_tree = self.make_branch_and_tree('tree')
 
238
        self.build_tree(['tree/file', 'tree/versioned-file'])
 
239
        work_tree.add(['file', 'versioned-file'])
 
240
        work_tree.commit('add files')
 
241
        work_tree.remove('file')
 
242
        tree = self._convert_tree(work_tree)
 
243
        if isinstance(tree,
 
244
                      (revisiontree.RevisionTree,
 
245
                       workingtree_4.DirStateRevisionTree)):
 
246
            expected = []
 
247
        else:
 
248
            expected = ['file']
 
249
        tree.lock_read()
 
250
        self.addCleanup(tree.unlock)
 
251
        self.assertEqual(expected, list(tree.extras()))
 
252
 
 
253
 
 
254
class TestGetFileSha1(TestCaseWithTree):
 
255
 
 
256
    def test_get_file_sha1(self):
 
257
        work_tree = self.make_branch_and_tree('tree')
 
258
        self.build_tree_contents([('tree/file', 'file content')])
 
259
        work_tree.add('file', 'file-id')
 
260
        tree = self._convert_tree(work_tree)
 
261
        tree.lock_read()
 
262
        self.addCleanup(tree.unlock)
 
263
        expected = osutils.sha_strings('file content')
 
264
        self.assertEqual(expected, tree.get_file_sha1('file-id'))