~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_dirstate.py

  • Committer: Alexander Belchenko
  • Date: 2008-02-16 10:03:17 UTC
  • mfrom: (3224 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3230.
  • Revision ID: bialix@ukr.net-20080216100317-xg1hdw306evlgt94
merge bzr.dev; update for 1.3; $BZR_LOG used in trace.py module (again), not in the main bzr script (req. by Robert Collins)

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