~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_dirstate.py

  • Committer: Martin Pool
  • Date: 2007-03-04 05:11:09 UTC
  • mto: (2255.11.3 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: mbp@sourcefrog.net-20070304051109-r2yzx82ncucuwiqj
Add support for tree-references in dirstate

Show diffs side-by-side

added added

removed removed

Lines of Context:
726
726
        finally:
727
727
            state.unlock()
728
728
 
 
729
    def test_add_tree_reference(self):
 
730
        # make a dirstate and add a tree reference
 
731
        state = dirstate.DirState.initialize('dirstate')
 
732
        expected_entry = (
 
733
            ('', 'subdir', 'subdir-id'),
 
734
            [('t', 'subtree-123123', 0, False,
 
735
              'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')],
 
736
            )
 
737
        try:
 
738
            state.add('subdir', 'subdir-id', 'tree-reference', None, 'subtree-123123')
 
739
            entry = state._get_entry(0, 'subdir-id', 'subdir')
 
740
            self.assertEqual(entry, expected_entry)
 
741
            state._validate()
 
742
            state.save()
 
743
        finally:
 
744
            state.unlock()
 
745
        # now check we can read it back
 
746
        state.lock_read()
 
747
        state._validate()
 
748
        try:
 
749
            entry2 = state._get_entry(0, 'subdir-id', 'subdir')
 
750
            self.assertEqual(entry, entry2)
 
751
            self.assertEqual(entry, expected_entry)
 
752
            # and lookup by id should work too
 
753
            entry2 = state._get_entry(0, fileid_utf8='subdir-id')
 
754
            self.assertEqual(entry, expected_entry)
 
755
        finally:
 
756
            state.unlock()
 
757
 
729
758
 
730
759
class TestGetLines(TestCaseWithDirState):
731
760