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

Merge the 2.3 branch changes up to 2.4. The final changes are
too invasive to do in a stable series (IMO).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2062
2062
        self.assertEqual('file.moved', target.id2path('lower-id'))
2063
2063
        self.assertEqual('FILE', target.id2path('upper-id'))
2064
2064
 
 
2065
    def test_build_tree_observes_sha(self):
 
2066
        source = self.make_branch_and_tree('source')
 
2067
        self.build_tree(['source/file1', 'source/dir/', 'source/dir/file2'])
 
2068
        source.add(['file1', 'dir', 'dir/file2'],
 
2069
                   ['file1-id', 'dir-id', 'file2-id'])
 
2070
        source.commit('new files')
 
2071
        target = self.make_branch_and_tree('target')
 
2072
        target.lock_write()
 
2073
        self.addCleanup(target.unlock)
 
2074
        # We make use of the fact that DirState caches its cutoff time. So we
 
2075
        # set the 'safe' time to one minute in the future.
 
2076
        state = target.current_dirstate()
 
2077
        state._cutoff_time = time.time() + 60
 
2078
        build_tree(source.basis_tree(), target)
 
2079
        entry1_sha = osutils.sha_file_by_name('source/file1')
 
2080
        entry2_sha = osutils.sha_file_by_name('source/dir/file2')
 
2081
        # entry[1] is the state information, entry[1][0] is the state of the
 
2082
        # working tree, entry[1][0][1] is the sha value for the current working
 
2083
        # tree
 
2084
        entry1 = state._get_entry(0, path_utf8='file1')
 
2085
        self.assertEqual(entry1_sha, entry1[1][0][1])
 
2086
        # The 'size' field must also be set.
 
2087
        self.assertEqual(25, entry1[1][0][2])
 
2088
        entry1_state = entry1[1][0]
 
2089
        entry2 = state._get_entry(0, path_utf8='dir/file2')
 
2090
        self.assertEqual(entry2_sha, entry2[1][0][1])
 
2091
        self.assertEqual(29, entry2[1][0][2])
 
2092
        entry2_state = entry2[1][0]
 
2093
        # Now, make sure that we don't have to re-read the content. The
 
2094
        # packed_stat should match exactly.
 
2095
        self.assertEqual(entry1_sha, target.get_file_sha1('file1-id', 'file1'))
 
2096
        self.assertEqual(entry2_sha,
 
2097
                         target.get_file_sha1('file2-id', 'dir/file2'))
 
2098
        self.assertEqual(entry1_state, entry1[1][0])
 
2099
        self.assertEqual(entry2_state, entry2[1][0])
 
2100
 
2065
2101
 
2066
2102
class TestCommitTransform(tests.TestCaseWithTransport):
2067
2103