~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2011-05-11 11:35:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5851.
  • Revision ID: john@arbash-meinel.com-20110511113528-qepibuwxicjrbb2h
Break compatibility with python <2.6.

This includes auditing the code for places where we were doing
explicit 'sys.version' checks and removing them as appropriate.

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):
155
151
        wt.apply_inventory_delta([('', None, root_id, None),
156
152
            (None, '', 'root-id',
157
153
             inventory.InventoryDirectory('root-id', '', None))])
 
154
 
 
155
 
 
156
class TestTreeReference(TestCaseWithWorkingTree):
 
157
 
 
158
    def test_tree_reference_matches_inv(self):
 
159
        base = self.make_branch_and_tree('base')
 
160
        if not base.supports_tree_reference():
 
161
            raise tests.TestNotApplicable("wt doesn't support nested trees")
 
162
        # We add it as a directory, but it becomes a tree-reference
 
163
        base.add(['subdir'], ['subdir-id'], ['directory'])
 
164
        subdir = self.make_branch_and_tree('base/subdir')
 
165
        self.addCleanup(base.lock_read().unlock)
 
166
        # Note: we aren't strict about ie.kind being 'directory' here, what we
 
167
        # are strict about is that wt.inventory should match
 
168
        # wt.current_dirstate()'s idea about what files are where.
 
169
        ie = base.inventory['subdir-id']
 
170
        self.assertEqual('directory', ie.kind)
 
171
        path, ie = base.iter_entries_by_dir(['subdir-id']).next()
 
172
        self.assertEqual('subdir', path)
 
173
        self.assertEqual('tree-reference', ie.kind)