~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_parents.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:
21
21
 
22
22
from bzrlib import (
23
23
    errors,
24
 
    osutils,
25
24
    revision as _mod_revision,
26
 
    tests,
27
25
    )
28
26
from bzrlib.inventory import (
29
27
    Inventory,
365
363
        result_basis = tree.basis_tree()
366
364
        result_basis.lock_read()
367
365
        try:
368
 
            self.assertEqual(expected_inventory, result_basis.inventory)
 
366
            self.assertEqual(expected_inventory, result_basis.root_inventory)
369
367
        finally:
370
368
            result_basis.unlock()
371
369
 
396
394
                self._inventory = shape
397
395
 
398
396
            def get_file_text(self, file_id, path=None):
399
 
                ie = self.inventory[file_id]
 
397
                ie = self.root_inventory[file_id]
400
398
                if ie.kind != "file":
401
399
                    return ""
402
400
                return 'a' * ie.text_size
452
450
            self.add_dir(new_shape, new_revid, 'root-id', None, '')
453
451
 
454
452
    def assertTransitionFromBasisToShape(self, basis_shape, basis_revid,
455
 
        new_shape, new_revid, extra_parent=None):
 
453
        new_shape, new_revid, extra_parent=None, set_current_inventory=True):
456
454
        # set the inventory revision ids.
457
455
        basis_shape.revision_id = basis_revid
458
456
        new_shape.revision_id = new_revid
467
465
                parents.append(extra_parent)
468
466
            tree.set_parent_ids(parents)
469
467
        self.fake_up_revision(tree, new_revid, new_shape)
470
 
        # give tree an inventory of new_shape
471
 
        tree._write_inventory(new_shape)
 
468
        if set_current_inventory:
 
469
            # give tree an inventory of new_shape
 
470
            tree._write_inventory(new_shape)
472
471
        self.assertDeltaApplicationResultsInExpectedBasis(tree, new_revid,
473
472
            delta, new_shape)
474
473
        # The tree should be internally consistent; while this is a moderately
475
474
        # large hammer, this is a particularly sensitive area of code, so the
476
475
        # extra assurance is well worth it.
477
476
        tree._validate()
478
 
        osutils.rmtree('tree')
 
477
        # If tree.branch is remote
 
478
        if tree.user_url != tree.branch.user_url:
 
479
            # We have a lightweight checkout, delete both locations
 
480
            tree.branch.bzrdir.root_transport.delete_tree('.')
 
481
        tree.bzrdir.root_transport.delete_tree('.')
479
482
 
480
483
    def test_no_parents_just_root(self):
481
484
        """Test doing an empty commit - no parent, set a root only."""
762
765
        self.add_link(new_shape, old_revid, 'link-id-C', 'dir-id-B', 'C', 'D')
763
766
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
764
767
            new_shape, new_revid)
 
768
 
 
769
    def test_add_files_to_empty_directory(self):
 
770
        old_revid = 'old-parent'
 
771
        basis_shape = Inventory(root_id=None)
 
772
        self.add_dir(basis_shape, old_revid, 'root-id', None, '')
 
773
        self.add_dir(basis_shape, old_revid, 'dir-id-A', 'root-id', 'A')
 
774
        new_revid = 'new-parent'
 
775
        new_shape = Inventory(root_id=None)
 
776
        self.add_new_root(new_shape, old_revid, new_revid)
 
777
        self.add_dir(new_shape, old_revid, 'dir-id-A', 'root-id', 'A')
 
778
        self.add_file(new_shape, new_revid, 'file-id-B', 'dir-id-A', 'B',
 
779
            '1' * 32, 24)
 
780
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
 
781
                new_shape, new_revid, set_current_inventory=False)