/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_helpers.py

  • Committer: INADA Naoki
  • Date: 2011-05-17 00:45:09 UTC
  • mfrom: (5875 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5891.
  • Revision ID: songofacandy@gmail.com-20110517004509-q58negjbdjh7t6u1
mergeĀ fromĀ lp:bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
822
822
 
823
823
    def test_observed_sha1_cachable(self):
824
824
        state, entry = self.get_state_with_a()
 
825
        state.save()
825
826
        atime = time.time() - 10
826
827
        self.build_tree(['a'])
827
 
        statvalue = os.lstat('a')
828
 
        statvalue = test_dirstate._FakeStat(statvalue.st_size, atime, atime,
829
 
            statvalue.st_dev, statvalue.st_ino, statvalue.st_mode)
 
828
        statvalue = test_dirstate._FakeStat.from_stat(os.lstat('a'))
 
829
        statvalue.st_mtime = statvalue.st_ctime = atime
 
830
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
 
831
                         state._dirblock_state)
830
832
        state._observed_sha1(entry, "foo", statvalue)
831
833
        self.assertEqual('foo', entry[1][0][1])
832
834
        packed_stat = dirstate.pack_stat(statvalue)
833
835
        self.assertEqual(packed_stat, entry[1][0][4])
 
836
        self.assertEqual(dirstate.DirState.IN_MEMORY_HASH_MODIFIED,
 
837
                         state._dirblock_state)
834
838
 
835
839
    def test_observed_sha1_not_cachable(self):
836
840
        state, entry = self.get_state_with_a()
 
841
        state.save()
837
842
        oldval = entry[1][0][1]
838
843
        oldstat = entry[1][0][4]
839
844
        self.build_tree(['a'])
840
845
        statvalue = os.lstat('a')
 
846
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
 
847
                         state._dirblock_state)
841
848
        state._observed_sha1(entry, "foo", statvalue)
842
849
        self.assertEqual(oldval, entry[1][0][1])
843
850
        self.assertEqual(oldstat, entry[1][0][4])
 
851
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
 
852
                         state._dirblock_state)
844
853
 
845
854
    def test_update_entry(self):
846
855
        state, _ = self.get_state_with_a()
959
968
        # Dirblock is not updated (the link is too new)
960
969
        self.assertEqual([('l', '', 6, False, dirstate.DirState.NULLSTAT)],
961
970
                         entry[1])
962
 
        self.assertEqual(dirstate.DirState.IN_MEMORY_MODIFIED,
 
971
        # The file entry turned into a symlink, that is considered
 
972
        # HASH modified worthy.
 
973
        self.assertEqual(dirstate.DirState.IN_MEMORY_HASH_MODIFIED,
963
974
                         state._dirblock_state)
964
975
 
965
976
        # Because the stat_value looks new, we should re-read the target
 
977
        del state._log[:]
966
978
        link_or_sha1 = self.update_entry(state, entry, abspath='a',
967
979
                                          stat_value=stat_value)
968
980
        self.assertEqual('target', link_or_sha1)
969
 
        self.assertEqual([('read_link', 'a', ''),
970
 
                          ('read_link', 'a', ''),
971
 
                         ], state._log)
 
981
        self.assertEqual([('read_link', 'a', '')], state._log)
972
982
        self.assertEqual([('l', '', 6, False, dirstate.DirState.NULLSTAT)],
973
983
                         entry[1])
 
984
        state.save()
974
985
        state.adjust_time(+20) # Skip into the future, all files look old
 
986
        del state._log[:]
975
987
        link_or_sha1 = self.update_entry(state, entry, abspath='a',
976
988
                                          stat_value=stat_value)
 
989
        # The symlink stayed a symlink. So while it is new enough to cache, we
 
990
        # don't bother setting the flag, because it is not really worth saving
 
991
        # (when we stat the symlink, we'll have paged in the target.)
 
992
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
 
993
                         state._dirblock_state)
977
994
        self.assertEqual('target', link_or_sha1)
978
995
        # We need to re-read the link because only now can we cache it
979
 
        self.assertEqual([('read_link', 'a', ''),
980
 
                          ('read_link', 'a', ''),
981
 
                          ('read_link', 'a', ''),
982
 
                         ], state._log)
 
996
        self.assertEqual([('read_link', 'a', '')], state._log)
983
997
        self.assertEqual([('l', 'target', 6, False, packed_stat)],
984
998
                         entry[1])
985
999
 
 
1000
        del state._log[:]
986
1001
        # Another call won't re-read the link
987
 
        self.assertEqual([('read_link', 'a', ''),
988
 
                          ('read_link', 'a', ''),
989
 
                          ('read_link', 'a', ''),
990
 
                         ], state._log)
 
1002
        self.assertEqual([], state._log)
991
1003
        link_or_sha1 = self.update_entry(state, entry, abspath='a',
992
1004
                                          stat_value=stat_value)
993
1005
        self.assertEqual('target', link_or_sha1)