~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_inv.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2012, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
127
127
    self.addCleanup(tree.unlock)
128
128
    if not invalid_delta:
129
129
        tree._validate()
130
 
    return tree.inventory
 
130
    return tree.root_inventory
131
131
 
132
132
 
133
133
def _create_repo_revisions(repo, basis, delta, invalid_delta):
224
224
    basis_tree = tree.basis_tree()
225
225
    basis_tree.lock_read()
226
226
    test.addCleanup(basis_tree.unlock)
227
 
    basis_inv = basis_tree.inventory
 
227
    basis_inv = basis_tree.root_inventory
228
228
    if target_entries:
229
229
        basis_entries = list(basis_inv.iter_entries_by_dir())
230
230
        test.assertEqual(target_entries, basis_entries)
325
325
        inv = inventory.Inventory(root_id='someroot')
326
326
        inv.root.revision = 'therev'
327
327
        inv2 = inv.copy()
328
 
        self.assertEquals('someroot', inv2.root.file_id)
329
 
        self.assertEquals('therev', inv2.root.revision)
 
328
        self.assertEqual('someroot', inv2.root.file_id)
 
329
        self.assertEqual('therev', inv2.root.revision)
330
330
 
331
331
    def test_create_tree_reference(self):
332
332
        inv = inventory.Inventory('tree-root-123')
1101
1101
        delta = [("", None, base_inv.root.file_id, None),
1102
1102
            (None, "",  "myrootid", inv.root)]
1103
1103
        new_inv = base_inv.create_by_apply_delta(delta, "expectedid")
1104
 
        self.assertEquals(reference_inv.root, new_inv.root)
 
1104
        self.assertEqual(reference_inv.root, new_inv.root)
1105
1105
 
1106
1106
    def test_create_by_apply_delta_empty_add_child(self):
1107
1107
        inv = Inventory()
1393
1393
        self.assertEqual([u'ch\xefld'],
1394
1394
                         sorted(ie_dir._children.keys()))
1395
1395
 
 
1396
    def test_filter_change_in_renamed_subfolder(self):
 
1397
        inv = Inventory('tree-root')
 
1398
        src_ie = inv.add_path('src', 'directory', 'src-id')
 
1399
        inv.add_path('src/sub/', 'directory', 'sub-id')
 
1400
        a_ie = inv.add_path('src/sub/a', 'file', 'a-id')
 
1401
        a_ie.text_sha1 = osutils.sha_string('content\n')
 
1402
        a_ie.text_size = len('content\n')
 
1403
        chk_bytes = self.get_chk_bytes()
 
1404
        inv = CHKInventory.from_inventory(chk_bytes, inv)
 
1405
        inv = inv.create_by_apply_delta([
 
1406
            ("src/sub/a", "src/sub/a", "a-id", a_ie),
 
1407
            ("src", "src2", "src-id", src_ie),
 
1408
            ], 'new-rev-2')
 
1409
        new_inv = inv.filter(['a-id', 'src-id'])
 
1410
        self.assertEqual([
 
1411
            ('', 'tree-root'),
 
1412
            ('src', 'src-id'),
 
1413
            ('src/sub', 'sub-id'),
 
1414
            ('src/sub/a', 'a-id'),
 
1415
            ], [(path, ie.file_id) for path, ie in new_inv.iter_entries()])
1396
1416
 
1397
1417
class TestCHKInventoryExpand(tests.TestCaseWithMemoryTransport):
1398
1418
 
1532
1552
        repository = self.make_repository('.')
1533
1553
        tree = repository.revision_tree(revision.NULL_REVISION)
1534
1554
        inv = mutable_inventory_from_tree(tree)
1535
 
        self.assertEquals(revision.NULL_REVISION, inv.revision_id)
1536
 
        self.assertEquals(0, len(inv))
 
1555
        self.assertEqual(revision.NULL_REVISION, inv.revision_id)
 
1556
        self.assertEqual(0, len(inv))
1537
1557
 
1538
1558
    def test_some_files(self):
1539
1559
        wt = self.make_branch_and_tree('.')
1542
1562
        revid = wt.commit("commit")
1543
1563
        tree = wt.branch.repository.revision_tree(revid)
1544
1564
        inv = mutable_inventory_from_tree(tree)
1545
 
        self.assertEquals(revid, inv.revision_id)
1546
 
        self.assertEquals(2, len(inv))
1547
 
        self.assertEquals("a", inv['thefileid'].name)
 
1565
        self.assertEqual(revid, inv.revision_id)
 
1566
        self.assertEqual(2, len(inv))
 
1567
        self.assertEqual("a", inv['thefileid'].name)
1548
1568
        # The inventory should be mutable and independent of
1549
1569
        # the original tree
1550
 
        self.assertFalse(tree.inventory['thefileid'].executable)
 
1570
        self.assertFalse(tree.root_inventory['thefileid'].executable)
1551
1571
        inv['thefileid'].executable = True
1552
 
        self.assertFalse(tree.inventory['thefileid'].executable)
 
1572
        self.assertFalse(tree.root_inventory['thefileid'].executable)