/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_dirstate.py

  • Committer: Aaron Bentley
  • Date: 2008-02-24 16:42:13 UTC
  • mfrom: (3234 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3235.
  • Revision ID: aaron@aaronbentley.com-20080224164213-eza1lzru5bwuwmmj
Merge with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
646
646
        finally:
647
647
            state.unlock()
648
648
 
 
649
    def test_save_refuses_if_changes_aborted(self):
 
650
        self.build_tree(['a-file', 'a-dir/'])
 
651
        state = dirstate.DirState.initialize('dirstate')
 
652
        try:
 
653
            # No stat and no sha1 sum.
 
654
            state.add('a-file', 'a-file-id', 'file', None, '')
 
655
            state.save()
 
656
        finally:
 
657
            state.unlock()
 
658
 
 
659
        # The dirstate should include TREE_ROOT and 'a-file' and nothing else
 
660
        expected_blocks = [
 
661
            ('', [(('', '', 'TREE_ROOT'),
 
662
                   [('d', '', 0, False, dirstate.DirState.NULLSTAT)])]),
 
663
            ('', [(('', 'a-file', 'a-file-id'),
 
664
                   [('f', '', 0, False, dirstate.DirState.NULLSTAT)])]),
 
665
        ]
 
666
 
 
667
        state = dirstate.DirState.on_file('dirstate')
 
668
        state.lock_write()
 
669
        try:
 
670
            state._read_dirblocks_if_needed()
 
671
            self.assertEqual(expected_blocks, state._dirblocks)
 
672
 
 
673
            # Now modify the state, but mark it as inconsistent
 
674
            state.add('a-dir', 'a-dir-id', 'directory', None, '')
 
675
            state._changes_aborted = True
 
676
            state.save()
 
677
        finally:
 
678
            state.unlock()
 
679
 
 
680
        state = dirstate.DirState.on_file('dirstate')
 
681
        state.lock_read()
 
682
        try:
 
683
            state._read_dirblocks_if_needed()
 
684
            self.assertEqual(expected_blocks, state._dirblocks)
 
685
        finally:
 
686
            state.unlock()
 
687
 
649
688
 
650
689
class TestDirStateInitialize(TestCaseWithDirState):
651
690