~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_inv.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-04-20 01:22:13 UTC
  • mfrom: (5802.1.2 mutable-inv-from-tree)
  • Revision ID: pqm@pqm.ubuntu.com-20110420012213-nagud1jxln5o6j36
(jelmer) Split Inventory._get_mutable_inventory() out into
 mutable_inventory_from_tree. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    InventoryDirectory,
35
35
    InventoryEntry,
36
36
    TreeReference,
 
37
    mutable_inventory_from_tree,
37
38
    )
38
39
from bzrlib.tests import (
39
40
    TestCase,
1436
1437
        inv = self.make_simple_inventory()
1437
1438
        self.assertExpand(['TREE_ROOT', 'dir1-id', 'sub-dir1-id', 'top-id',
1438
1439
                           'subsub-file1-id'], inv, ['top-id', 'subsub-file1-id'])
 
1440
 
 
1441
 
 
1442
class TestMutableInventoryFromTree(TestCaseWithTransport):
 
1443
 
 
1444
    def test_empty(self):
 
1445
        repository = self.make_repository('.')
 
1446
        tree = repository.revision_tree(revision.NULL_REVISION)
 
1447
        inv = mutable_inventory_from_tree(tree)
 
1448
        self.assertEquals(revision.NULL_REVISION, inv.revision_id)
 
1449
        self.assertEquals(0, len(inv))
 
1450
 
 
1451
    def test_some_files(self):
 
1452
        wt = self.make_branch_and_tree('.')
 
1453
        self.build_tree(['a'])
 
1454
        wt.add(['a'], ['thefileid'])
 
1455
        revid = wt.commit("commit")
 
1456
        tree = wt.branch.repository.revision_tree(revid)
 
1457
        inv = mutable_inventory_from_tree(tree)
 
1458
        self.assertEquals(revid, inv.revision_id)
 
1459
        self.assertEquals(2, len(inv))
 
1460
        self.assertEquals("a", inv['thefileid'].name)
 
1461
        # The inventory should be mutable and independent of
 
1462
        # the original tree
 
1463
        self.assertFalse(tree.inventory['thefileid'].executable)
 
1464
        inv['thefileid'].executable = True
 
1465
        self.assertFalse(tree.inventory['thefileid'].executable)