~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_dirstate.py

  • Committer: John Arbash Meinel
  • Date: 2007-05-21 11:28:14 UTC
  • mto: This revision was merged to the branch mainline in revision 2518.
  • Revision ID: john@arbash-meinel.com-20070521112814-156v4tp2oyya2oqb
Adding a (broken) test that set_state_from_inventory works
when a record is deleted from a directory which has a sibling directory with a common prefix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
688
688
            # This will unlock it
689
689
            self.check_state_with_reopen(expected_result, state)
690
690
 
 
691
    def test_set_state_from_inventory_mixed_paths(self):
 
692
        tree1 = self.make_branch_and_tree('tree1')
 
693
        self.build_tree(['tree1/a/', 'tree1/a/b/', 'tree1/a-b/',
 
694
                         'tree1/a/b/foo', 'tree1/a-b/bar'])
 
695
        tree1.lock_write()
 
696
        try:
 
697
            tree1.add(['a', 'a/b', 'a-b', 'a/b/foo', 'a-b/bar'],
 
698
                      ['a-id', 'b-id', 'a-b-id', 'foo-id', 'bar-id'])
 
699
            tree1.commit('rev1', rev_id='rev1')
 
700
            root_id = tree1.get_root_id()
 
701
            inv = tree1.inventory
 
702
        finally:
 
703
            tree1.unlock()
 
704
        expected_result1 = [('', '', root_id, 'd'),
 
705
                            ('', 'a', 'a-id', 'd'),
 
706
                            ('', 'a-b', 'a-b-id', 'd'),
 
707
                            ('a', 'b', 'b-id', 'd'),
 
708
                            ('a/b', 'foo', 'foo-id', 'f'),
 
709
                            ('a-b', 'bar', 'bar-id', 'f'),
 
710
                           ]
 
711
        expected_result2 = [('', '', root_id, 'd'),
 
712
                            ('', 'a', 'a-id', 'd'),
 
713
                            ('', 'a-b', 'a-b-id', 'd'),
 
714
                            ('a-b', 'bar', 'bar-id', 'f'),
 
715
                           ]
 
716
        state = dirstate.DirState.initialize('dirstate')
 
717
        try:
 
718
            state.set_state_from_inventory(inv)
 
719
            values = []
 
720
            for entry in state._iter_entries():
 
721
                values.append(entry[0] + entry[1][0][:1])
 
722
            self.assertEqual(expected_result1, values)
 
723
            del inv['b-id']
 
724
            state.set_state_from_inventory(inv)
 
725
            values = []
 
726
            for entry in state._iter_entries():
 
727
                values.append(entry[0] + entry[1][0][:1])
 
728
            self.assertEqual(expected_result2, values)
 
729
        finally:
 
730
            state.unlock()
 
731
 
691
732
    def test_set_path_id_no_parents(self):
692
733
        """The id of a path can be changed trivally with no parents."""
693
734
        state = dirstate.DirState.initialize('dirstate')