~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__dirstate_helpers.py

(jameinel) Fix bug #765881,
 we don't need to save the dirstate file for trivial changes. (John A Meinel)

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 cached the file's sha1 (too new)
 
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
875
877
        self.assertEqual(('f', '', 14, False, dirstate.DirState.NULLSTAT),
876
878
                         entry[1][0])
877
 
        self.assertEqual(dirstate.DirState.IN_MEMORY_MODIFIED,
 
879
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
878
880
                         state._dirblock_state)
879
881
        mode = stat_value.st_mode
880
882
        self.assertEqual([('is_exec', mode, False)], state._log)
883
885
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
884
886
                         state._dirblock_state)
885
887
 
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.
 
888
        # Roll the clock back so the file is guaranteed to look too new. We
 
889
        # should still not compute the sha1.
889
890
        state.adjust_time(-10)
890
891
        del state._log[:]
891
892
 
893
894
                                          stat_value=stat_value)
894
895
        self.assertEqual([('is_exec', mode, False)], state._log)
895
896
        self.assertEqual(None, link_or_sha1)
896
 
        self.assertEqual(dirstate.DirState.IN_MEMORY_MODIFIED,
 
897
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
897
898
                         state._dirblock_state)
898
899
        self.assertEqual(('f', '', 14, False, dirstate.DirState.NULLSTAT),
899
900
                         entry[1][0])
909
910
        self.assertEqual([('is_exec', mode, False)], state._log)
910
911
        self.assertEqual(('f', '', 14, False, dirstate.DirState.NULLSTAT),
911
912
                         entry[1][0])
 
913
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
 
914
                         state._dirblock_state)
912
915
 
913
916
        # If the file is no longer new, and the clock has been moved forward
914
917
        # sufficiently, it will cache the sha.
1005
1008
        self.build_tree(['a/'])
1006
1009
        state.adjust_time(+20)
1007
1010
        self.assertIs(None, self.do_update_entry(state, entry, 'a'))
 
1011
        # a/ used to be a file, but is now a directory, worth saving
1008
1012
        self.assertEqual(dirstate.DirState.IN_MEMORY_MODIFIED,
1009
1013
                         state._dirblock_state)
1010
1014
        state.save()
1011
1015
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
1012
1016
                         state._dirblock_state)
1013
 
        self.assertIs(None, self.do_update_entry(state, entry, 'a'))
 
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
        os.utime('a', (t, t))
 
1024
        saved_packed_stat = entry[1][0][-1]
 
1025
        self.assertIs(None, self.do_update_entry(state, entry, 'a'))
 
1026
        # We *do* go ahead and update the information in the dirblocks, but we
 
1027
        # don't bother setting IN_MEMORY_MODIFIED because it is trivial to
 
1028
        # recompute.
 
1029
        self.assertNotEqual(saved_packed_stat, entry[1][0][-1])
1014
1030
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
1015
1031
                         state._dirblock_state)
1016
1032