~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_dirstate.py

  • Committer: Jelmer Vernooij
  • Date: 2012-04-16 11:08:11 UTC
  • mfrom: (6521 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6522.
  • Revision ID: jelmer@samba.org-20120416110811-0y996ihqy9o2bb1t
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import tempfile
21
21
 
22
22
from bzrlib import (
23
 
    bzrdir,
 
23
    controldir,
24
24
    dirstate,
25
25
    errors,
26
26
    inventory,
31
31
    tests,
32
32
    workingtree_4,
33
33
    )
34
 
from bzrlib.transport import memory
35
34
from bzrlib.tests import (
36
35
    features,
37
36
    test_osutils,
756
755
    def test_set_state_from_inventory_no_content_no_parents(self):
757
756
        # setting the current inventory is a slow but important api to support.
758
757
        tree1, revid1 = self.make_minimal_tree()
759
 
        inv = tree1.inventory
 
758
        inv = tree1.root_inventory
760
759
        root_id = inv.path2id('')
761
760
        expected_result = [], [
762
761
            (('', '', root_id), [
777
776
 
778
777
    def test_set_state_from_scratch_no_parents(self):
779
778
        tree1, revid1 = self.make_minimal_tree()
780
 
        inv = tree1.inventory
 
779
        inv = tree1.root_inventory
781
780
        root_id = inv.path2id('')
782
781
        expected_result = [], [
783
782
            (('', '', root_id), [
798
797
 
799
798
    def test_set_state_from_scratch_identical_parent(self):
800
799
        tree1, revid1 = self.make_minimal_tree()
801
 
        inv = tree1.inventory
 
800
        inv = tree1.root_inventory
802
801
        root_id = inv.path2id('')
803
802
        rev_tree1 = tree1.branch.repository.revision_tree(revid1)
804
803
        d_entry = ('d', '', 0, False, dirstate.DirState.NULLSTAT)
856
855
                tree._dirstate._get_entry(0, 'foo-id'))
857
856
 
858
857
            # extract the inventory, and add something to it
859
 
            inv = tree._get_inventory()
 
858
            inv = tree._get_root_inventory()
860
859
            # should see the file we poked in...
861
860
            self.assertTrue(inv.has_id('foo-id'))
862
861
            self.assertTrue(inv.has_filename('foo'))
892
891
                      ['a-id', 'b-id', 'a-b-id', 'foo-id', 'bar-id'])
893
892
            tree1.commit('rev1', rev_id='rev1')
894
893
            root_id = tree1.get_root_id()
895
 
            inv = tree1.inventory
 
894
            inv = tree1.root_inventory
896
895
        finally:
897
896
            tree1.unlock()
898
897
        expected_result1 = [('', '', root_id, 'd'),
1326
1325
        try:
1327
1326
            tree1.add(['b'], ['b-id'])
1328
1327
            root_id = tree1.get_root_id()
1329
 
            inv = tree1.inventory
 
1328
            inv = tree1.root_inventory
1330
1329
            state = dirstate.DirState.initialize('dirstate')
1331
1330
            try:
1332
1331
                # Set the initial state with 'b'
2210
2209
class TestDirstateTreeReference(TestCaseWithDirState):
2211
2210
 
2212
2211
    def test_reference_revision_is_none(self):
2213
 
        tree = self.make_branch_and_tree('tree', format='dirstate-with-subtree')
 
2212
        tree = self.make_branch_and_tree('tree', format='development-subtree')
2214
2213
        subtree = self.make_branch_and_tree('tree/subtree',
2215
 
                            format='dirstate-with-subtree')
 
2214
                            format='development-subtree')
2216
2215
        subtree.set_root_id('subtree')
2217
2216
        tree.add_reference(subtree)
2218
2217
        tree.add('subtree')
2444
2443
    """A minimal api to get InventoryRevisionTree to work."""
2445
2444
 
2446
2445
    def __init__(self):
2447
 
        default_format = bzrdir.format_registry.make_bzrdir('default')
 
2446
        default_format = controldir.format_registry.make_bzrdir('default')
2448
2447
        self._format = default_format.repository_format
2449
2448
 
2450
2449
    def lock_read(self):
2527
2526
        basis_tree = self.create_tree_from_shape('basis', basis)
2528
2527
        target_tree = self.create_tree_from_shape('target', target)
2529
2528
        state = self.create_empty_dirstate()
2530
 
        state.set_state_from_scratch(active_tree.inventory,
 
2529
        state.set_state_from_scratch(active_tree.root_inventory,
2531
2530
            [('basis', basis_tree)], [])
2532
 
        delta = target_tree.inventory._make_delta(basis_tree.inventory)
 
2531
        delta = target_tree.root_inventory._make_delta(
 
2532
            basis_tree.root_inventory)
2533
2533
        state.update_basis_by_delta(delta, 'target')
2534
2534
        state._validate()
2535
2535
        dirstate_tree = workingtree_4.DirStateRevisionTree(state,
2540
2540
        # And the dirblock state should be identical to the state if we created
2541
2541
        # it from scratch.
2542
2542
        state2 = self.create_empty_dirstate()
2543
 
        state2.set_state_from_scratch(active_tree.inventory,
 
2543
        state2.set_state_from_scratch(active_tree.root_inventory,
2544
2544
            [('target', target_tree)], [])
2545
2545
        self.assertEqual(state2._dirblocks, state._dirblocks)
2546
2546
        return state
2561
2561
        basis_tree = self.create_tree_from_shape('basis', basis)
2562
2562
        inv_delta = self.create_inv_delta(delta, 'target')
2563
2563
        state = self.create_empty_dirstate()
2564
 
        state.set_state_from_scratch(active_tree.inventory,
 
2564
        state.set_state_from_scratch(active_tree.root_inventory,
2565
2565
            [('basis', basis_tree)], [])
2566
2566
        self.assertRaises(errors.InconsistentDelta,
2567
2567
            state.update_basis_by_delta, inv_delta, 'target')