~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_inv.py

resolve conflicts against trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
 
20
20
import os
21
 
import time
22
21
 
23
 
from bzrlib import (
24
 
    errors,
25
 
    inventory,
26
 
    )
 
22
from bzrlib import inventory, tests
27
23
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
28
24
 
29
25
 
33
29
        wt = self.make_branch_and_tree('b1')
34
30
        wt.lock_tree_write()
35
31
        self.addCleanup(wt.unlock)
36
 
        self.assertEqual(len(wt.inventory), 1)
 
32
        self.assertEqual(len(wt.all_file_ids()), 1)
37
33
        open('b1/a', 'wb').write('a test\n')
38
34
        wt.add('a')
39
 
        self.assertEqual(len(wt.inventory), 2)
 
35
        self.assertEqual(len(wt.all_file_ids()), 2)
40
36
        wt.flush() # workaround revert doing wt._write_inventory for now.
41
37
        os.unlink('b1/a')
42
38
        wt.revert()
43
 
        self.assertEqual(len(wt.inventory), 1)
 
39
        self.assertEqual(len(wt.all_file_ids()), 1)
44
40
 
45
41
 
46
42
class TestApplyInventoryDelta(TestCaseWithWorkingTree):
47
43
 
 
44
    def setUp(self):
 
45
        super(TestApplyInventoryDelta, self).setUp()
 
46
        if not self.bzrdir_format.repository_format.supports_full_versioned_files:
 
47
            raise tests.TestNotApplicable(
 
48
                "format does not support inventory deltas")
 
49
 
48
50
    def test_add(self):
49
51
        wt = self.make_branch_and_tree('.')
50
52
        wt.lock_write()
155
157
        wt.apply_inventory_delta([('', None, root_id, None),
156
158
            (None, '', 'root-id',
157
159
             inventory.InventoryDirectory('root-id', '', None))])
 
160
 
 
161
 
 
162
class TestTreeReference(TestCaseWithWorkingTree):
 
163
 
 
164
    def test_tree_reference_matches_inv(self):
 
165
        base = self.make_branch_and_tree('base')
 
166
        if base.branch.repository._format.supports_full_versioned_files:
 
167
            raise tests.TestNotApplicable(
 
168
                "format does not support inventory deltas")
 
169
        if not base.supports_tree_reference():
 
170
            raise tests.TestNotApplicable("wt doesn't support nested trees")
 
171
        # We add it as a directory, but it becomes a tree-reference
 
172
        base.add(['subdir'], ['subdir-id'], ['directory'])
 
173
        subdir = self.make_branch_and_tree('base/subdir')
 
174
        self.addCleanup(base.lock_read().unlock)
 
175
        # Note: we aren't strict about ie.kind being 'directory' here, what we
 
176
        # are strict about is that wt.inventory should match
 
177
        # wt.current_dirstate()'s idea about what files are where.
 
178
        ie = base.inventory['subdir-id']
 
179
        self.assertEqual('directory', ie.kind)
 
180
        path, ie = base.iter_entries_by_dir(['subdir-id']).next()
 
181
        self.assertEqual('subdir', path)
 
182
        self.assertEqual('tree-reference', ie.kind)