726
726
class TestDirStateManipulations(TestCaseWithDirState):
728
def make_minimal_tree(self):
729
tree1 = self.make_branch_and_memory_tree('tree1')
731
self.addCleanup(tree1.unlock)
733
revid1 = tree1.commit('foo')
728
736
def test_update_minimal_updates_id_index(self):
729
737
state = self.create_dirstate_with_root_and_subdir()
730
738
self.addCleanup(state.unlock)
744
752
def test_set_state_from_inventory_no_content_no_parents(self):
745
753
# setting the current inventory is a slow but important api to support.
746
tree1 = self.make_branch_and_memory_tree('tree1')
750
revid1 = tree1.commit('foo').encode('utf8')
751
root_id = tree1.get_root_id()
752
inv = tree1.inventory
754
tree1, revid1 = self.make_minimal_tree()
755
inv = tree1.inventory
756
root_id = inv.path2id('')
755
757
expected_result = [], [
756
758
(('', '', root_id), [
757
759
('d', '', 0, False, dirstate.DirState.NULLSTAT)])]
769
771
# This will unlock it
770
772
self.check_state_with_reopen(expected_result, state)
774
def test_set_state_from_scratch_no_parents(self):
775
tree1, revid1 = self.make_minimal_tree()
776
inv = tree1.inventory
777
root_id = inv.path2id('')
778
expected_result = [], [
779
(('', '', root_id), [
780
('d', '', 0, False, dirstate.DirState.NULLSTAT)])]
781
state = dirstate.DirState.initialize('dirstate')
783
state.set_state_from_scratch(inv, [], [])
784
self.assertEqual(dirstate.DirState.IN_MEMORY_MODIFIED,
786
self.assertEqual(dirstate.DirState.IN_MEMORY_MODIFIED,
787
state._dirblock_state)
792
# This will unlock it
793
self.check_state_with_reopen(expected_result, state)
795
def test_set_state_from_scratch_identical_parent(self):
796
tree1, revid1 = self.make_minimal_tree()
797
inv = tree1.inventory
798
root_id = inv.path2id('')
799
rev_tree1 = tree1.branch.repository.revision_tree(revid1)
800
d_entry = ('d', '', 0, False, dirstate.DirState.NULLSTAT)
801
parent_entry = ('d', '', 0, False, revid1)
802
expected_result = [revid1], [
803
(('', '', root_id), [d_entry, parent_entry])]
804
state = dirstate.DirState.initialize('dirstate')
806
state.set_state_from_scratch(inv, [(revid1, rev_tree1)], [])
807
self.assertEqual(dirstate.DirState.IN_MEMORY_MODIFIED,
809
self.assertEqual(dirstate.DirState.IN_MEMORY_MODIFIED,
810
state._dirblock_state)
815
# This will unlock it
816
self.check_state_with_reopen(expected_result, state)
772
818
def test_set_state_from_inventory_preserves_hashcache(self):
773
819
# https://bugs.launchpad.net/bzr/+bug/146176
774
820
# set_state_from_inventory should preserve the stat and hash value for