~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-15 11:26:00 UTC
  • mfrom: (5757.7.7 knitpackrepo-6)
  • mto: This revision was merged to the branch mainline in revision 5801.
  • Revision ID: jelmer@samba.org-20110415112600-vrv2431lh3gi6wx2
MergeĀ knitpackrepo-6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1970
1970
        self.addCleanup(target.unlock)
1971
1971
        self.assertEqual([], list(target.iter_changes(revision_tree)))
1972
1972
 
 
1973
    def test_build_tree_accelerator_tree_observes_sha1(self):
 
1974
        source = self.create_ab_tree()
 
1975
        sha1 = osutils.sha_string('A')
 
1976
        target = self.make_branch_and_tree('target')
 
1977
        target.lock_write()
 
1978
        self.addCleanup(target.unlock)
 
1979
        state = target.current_dirstate()
 
1980
        state._cutoff_time = time.time() + 60
 
1981
        build_tree(source.basis_tree(), target, source)
 
1982
        entry = state._get_entry(0, path_utf8='file1')
 
1983
        self.assertEqual(sha1, entry[1][0][1])
 
1984
 
1973
1985
    def test_build_tree_accelerator_tree_missing_file(self):
1974
1986
        source = self.create_ab_tree()
1975
1987
        os.unlink('source/file1')
2133
2145
        self.assertEqual('file.moved', target.id2path('lower-id'))
2134
2146
        self.assertEqual('FILE', target.id2path('upper-id'))
2135
2147
 
 
2148
    def test_build_tree_observes_sha(self):
 
2149
        source = self.make_branch_and_tree('source')
 
2150
        self.build_tree(['source/file1', 'source/dir/', 'source/dir/file2'])
 
2151
        source.add(['file1', 'dir', 'dir/file2'],
 
2152
                   ['file1-id', 'dir-id', 'file2-id'])
 
2153
        source.commit('new files')
 
2154
        target = self.make_branch_and_tree('target')
 
2155
        target.lock_write()
 
2156
        self.addCleanup(target.unlock)
 
2157
        # We make use of the fact that DirState caches its cutoff time. So we
 
2158
        # set the 'safe' time to one minute in the future.
 
2159
        state = target.current_dirstate()
 
2160
        state._cutoff_time = time.time() + 60
 
2161
        build_tree(source.basis_tree(), target)
 
2162
        entry1_sha = osutils.sha_file_by_name('source/file1')
 
2163
        entry2_sha = osutils.sha_file_by_name('source/dir/file2')
 
2164
        # entry[1] is the state information, entry[1][0] is the state of the
 
2165
        # working tree, entry[1][0][1] is the sha value for the current working
 
2166
        # tree
 
2167
        entry1 = state._get_entry(0, path_utf8='file1')
 
2168
        self.assertEqual(entry1_sha, entry1[1][0][1])
 
2169
        # The 'size' field must also be set.
 
2170
        self.assertEqual(25, entry1[1][0][2])
 
2171
        entry1_state = entry1[1][0]
 
2172
        entry2 = state._get_entry(0, path_utf8='dir/file2')
 
2173
        self.assertEqual(entry2_sha, entry2[1][0][1])
 
2174
        self.assertEqual(29, entry2[1][0][2])
 
2175
        entry2_state = entry2[1][0]
 
2176
        # Now, make sure that we don't have to re-read the content. The
 
2177
        # packed_stat should match exactly.
 
2178
        self.assertEqual(entry1_sha, target.get_file_sha1('file1-id', 'file1'))
 
2179
        self.assertEqual(entry2_sha,
 
2180
                         target.get_file_sha1('file2-id', 'dir/file2'))
 
2181
        self.assertEqual(entry1_state, entry1[1][0])
 
2182
        self.assertEqual(entry2_state, entry2[1][0])
 
2183
 
2136
2184
 
2137
2185
class TestCommitTransform(tests.TestCaseWithTransport):
2138
2186