~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__dirstate_helpers.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-04-16 01:09:56 UTC
  • mfrom: (5784.1.4 760435-less-fail)
  • Revision ID: pqm@pqm.ubuntu.com-20110416010956-5wrpm136qq2hz5f3
(mbp) rename and deprecate failUnlessExists and failIfExists (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
871
871
                                          stat_value=stat_value)
872
872
        self.assertEqual(None, link_or_sha1)
873
873
 
874
 
        # The dirblock entry should not have computed or cached the file's
875
 
        # sha1, but it did update the files' st_size. However, this is not
876
 
        # worth writing a dirstate file for, so we leave the state UNMODIFIED
 
874
        # The dirblock entry should not have cached the file's sha1 (too new)
877
875
        self.assertEqual(('f', '', 14, False, dirstate.DirState.NULLSTAT),
878
876
                         entry[1][0])
879
 
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
 
877
        self.assertEqual(dirstate.DirState.IN_MEMORY_MODIFIED,
880
878
                         state._dirblock_state)
881
879
        mode = stat_value.st_mode
882
880
        self.assertEqual([('is_exec', mode, False)], state._log)
885
883
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
886
884
                         state._dirblock_state)
887
885
 
888
 
        # Roll the clock back so the file is guaranteed to look too new. We
889
 
        # should still not compute the sha1.
 
886
        # If we do it again right away, we don't know if the file has changed
 
887
        # so we will re-read the file. Roll the clock back so the file is
 
888
        # guaranteed to look too new.
890
889
        state.adjust_time(-10)
891
890
        del state._log[:]
892
891
 
894
893
                                          stat_value=stat_value)
895
894
        self.assertEqual([('is_exec', mode, False)], state._log)
896
895
        self.assertEqual(None, link_or_sha1)
897
 
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
 
896
        self.assertEqual(dirstate.DirState.IN_MEMORY_MODIFIED,
898
897
                         state._dirblock_state)
899
898
        self.assertEqual(('f', '', 14, False, dirstate.DirState.NULLSTAT),
900
899
                         entry[1][0])
910
909
        self.assertEqual([('is_exec', mode, False)], state._log)
911
910
        self.assertEqual(('f', '', 14, False, dirstate.DirState.NULLSTAT),
912
911
                         entry[1][0])
913
 
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
914
 
                         state._dirblock_state)
915
912
 
916
913
        # If the file is no longer new, and the clock has been moved forward
917
914
        # sufficiently, it will cache the sha.
1008
1005
        self.build_tree(['a/'])
1009
1006
        state.adjust_time(+20)
1010
1007
        self.assertIs(None, self.do_update_entry(state, entry, 'a'))
1011
 
        # a/ used to be a file, but is now a directory, worth saving
1012
1008
        self.assertEqual(dirstate.DirState.IN_MEMORY_MODIFIED,
1013
1009
                         state._dirblock_state)
1014
1010
        state.save()
1015
1011
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
1016
1012
                         state._dirblock_state)
1017
 
        # No changes to a/ means not worth saving.
1018
 
        self.assertIs(None, self.do_update_entry(state, entry, 'a'))
1019
 
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
1020
 
                         state._dirblock_state)
1021
 
        # Change the last-modified time for the directory
1022
 
        t = time.time() - 100.0
1023
 
        try:
1024
 
            os.utime('a', (t, t))
1025
 
        except OSError:
1026
 
            # It looks like Win32 + FAT doesn't allow to change times on a dir.
1027
 
            raise tests.TestSkipped("can't update mtime of a dir on FAT")
1028
 
        saved_packed_stat = entry[1][0][-1]
1029
 
        self.assertIs(None, self.do_update_entry(state, entry, 'a'))
1030
 
        # We *do* go ahead and update the information in the dirblocks, but we
1031
 
        # don't bother setting IN_MEMORY_MODIFIED because it is trivial to
1032
 
        # recompute.
1033
 
        self.assertNotEqual(saved_packed_stat, entry[1][0][-1])
 
1013
        self.assertIs(None, self.do_update_entry(state, entry, 'a'))
1034
1014
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
1035
1015
                         state._dirblock_state)
1036
1016