~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_dirstate.py

  • Committer: Vincent Ladeuil
  • Date: 2012-03-13 17:25:29 UTC
  • mfrom: (6499 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6501.
  • Revision ID: v.ladeuil+lp@free.fr-20120313172529-i0suyjnepsor25i7
Merge trunk

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
 
from bzrlib.tests import test_osutils
 
34
from bzrlib.tests import (
 
35
    features,
 
36
    test_osutils,
 
37
    )
36
38
from bzrlib.tests.scenarios import load_tests_apply_scenarios
37
39
 
38
40
 
753
755
    def test_set_state_from_inventory_no_content_no_parents(self):
754
756
        # setting the current inventory is a slow but important api to support.
755
757
        tree1, revid1 = self.make_minimal_tree()
756
 
        inv = tree1.inventory
 
758
        inv = tree1.root_inventory
757
759
        root_id = inv.path2id('')
758
760
        expected_result = [], [
759
761
            (('', '', root_id), [
774
776
 
775
777
    def test_set_state_from_scratch_no_parents(self):
776
778
        tree1, revid1 = self.make_minimal_tree()
777
 
        inv = tree1.inventory
 
779
        inv = tree1.root_inventory
778
780
        root_id = inv.path2id('')
779
781
        expected_result = [], [
780
782
            (('', '', root_id), [
795
797
 
796
798
    def test_set_state_from_scratch_identical_parent(self):
797
799
        tree1, revid1 = self.make_minimal_tree()
798
 
        inv = tree1.inventory
 
800
        inv = tree1.root_inventory
799
801
        root_id = inv.path2id('')
800
802
        rev_tree1 = tree1.branch.repository.revision_tree(revid1)
801
803
        d_entry = ('d', '', 0, False, dirstate.DirState.NULLSTAT)
853
855
                tree._dirstate._get_entry(0, 'foo-id'))
854
856
 
855
857
            # extract the inventory, and add something to it
856
 
            inv = tree._get_inventory()
 
858
            inv = tree._get_root_inventory()
857
859
            # should see the file we poked in...
858
860
            self.assertTrue(inv.has_id('foo-id'))
859
861
            self.assertTrue(inv.has_filename('foo'))
889
891
                      ['a-id', 'b-id', 'a-b-id', 'foo-id', 'bar-id'])
890
892
            tree1.commit('rev1', rev_id='rev1')
891
893
            root_id = tree1.get_root_id()
892
 
            inv = tree1.inventory
 
894
            inv = tree1.root_inventory
893
895
        finally:
894
896
            tree1.unlock()
895
897
        expected_result1 = [('', '', root_id, 'd'),
1209
1211
        # The most trivial addition of a symlink when there are no parents and
1210
1212
        # its in the root and all data about the file is supplied
1211
1213
        # bzr doesn't support fake symlinks on windows, yet.
1212
 
        self.requireFeature(tests.SymlinkFeature)
 
1214
        self.requireFeature(features.SymlinkFeature)
1213
1215
        os.symlink(target, link_name)
1214
1216
        stat = os.lstat(link_name)
1215
1217
        expected_entries = [
1240
1242
        self._test_add_symlink_to_root_no_parents_all_data('a link', 'target')
1241
1243
 
1242
1244
    def test_add_symlink_unicode_to_root_no_parents_all_data(self):
1243
 
        self.requireFeature(tests.UnicodeFilenameFeature)
 
1245
        self.requireFeature(features.UnicodeFilenameFeature)
1244
1246
        self._test_add_symlink_to_root_no_parents_all_data(
1245
1247
            u'\N{Euro Sign}link', u'targ\N{Euro Sign}et')
1246
1248
 
1323
1325
        try:
1324
1326
            tree1.add(['b'], ['b-id'])
1325
1327
            root_id = tree1.get_root_id()
1326
 
            inv = tree1.inventory
 
1328
            inv = tree1.root_inventory
1327
1329
            state = dirstate.DirState.initialize('dirstate')
1328
1330
            try:
1329
1331
                # Set the initial state with 'b'
2207
2209
class TestDirstateTreeReference(TestCaseWithDirState):
2208
2210
 
2209
2211
    def test_reference_revision_is_none(self):
2210
 
        tree = self.make_branch_and_tree('tree', format='dirstate-with-subtree')
 
2212
        tree = self.make_branch_and_tree('tree', format='development-subtree')
2211
2213
        subtree = self.make_branch_and_tree('tree/subtree',
2212
 
                            format='dirstate-with-subtree')
 
2214
                            format='development-subtree')
2213
2215
        subtree.set_root_id('subtree')
2214
2216
        tree.add_reference(subtree)
2215
2217
        tree.add('subtree')
2441
2443
    """A minimal api to get InventoryRevisionTree to work."""
2442
2444
 
2443
2445
    def __init__(self):
2444
 
        default_format = bzrdir.format_registry.make_bzrdir('default')
 
2446
        default_format = controldir.format_registry.make_bzrdir('default')
2445
2447
        self._format = default_format.repository_format
2446
2448
 
2447
2449
    def lock_read(self):
2524
2526
        basis_tree = self.create_tree_from_shape('basis', basis)
2525
2527
        target_tree = self.create_tree_from_shape('target', target)
2526
2528
        state = self.create_empty_dirstate()
2527
 
        state.set_state_from_scratch(active_tree.inventory,
 
2529
        state.set_state_from_scratch(active_tree.root_inventory,
2528
2530
            [('basis', basis_tree)], [])
2529
 
        delta = target_tree.inventory._make_delta(basis_tree.inventory)
 
2531
        delta = target_tree.root_inventory._make_delta(
 
2532
            basis_tree.root_inventory)
2530
2533
        state.update_basis_by_delta(delta, 'target')
2531
2534
        state._validate()
2532
2535
        dirstate_tree = workingtree_4.DirStateRevisionTree(state,
2537
2540
        # And the dirblock state should be identical to the state if we created
2538
2541
        # it from scratch.
2539
2542
        state2 = self.create_empty_dirstate()
2540
 
        state2.set_state_from_scratch(active_tree.inventory,
 
2543
        state2.set_state_from_scratch(active_tree.root_inventory,
2541
2544
            [('target', target_tree)], [])
2542
2545
        self.assertEqual(state2._dirblocks, state._dirblocks)
2543
2546
        return state
2558
2561
        basis_tree = self.create_tree_from_shape('basis', basis)
2559
2562
        inv_delta = self.create_inv_delta(delta, 'target')
2560
2563
        state = self.create_empty_dirstate()
2561
 
        state.set_state_from_scratch(active_tree.inventory,
 
2564
        state.set_state_from_scratch(active_tree.root_inventory,
2562
2565
            [('basis', basis_tree)], [])
2563
2566
        self.assertRaises(errors.InconsistentDelta,
2564
2567
            state.update_basis_by_delta, inv_delta, 'target')