1941
1941
self.addCleanup(target.unlock)
1942
1942
self.assertEqual([], list(target.iter_changes(revision_tree)))
1944
def test_build_tree_accelerator_tree_observes_sha1(self):
1945
source = self.create_ab_tree()
1946
sha1 = osutils.sha_string('A')
1947
target = self.make_branch_and_tree('target')
1949
self.addCleanup(target.unlock)
1950
state = target.current_dirstate()
1951
state._cutoff_time = time.time() + 60
1952
build_tree(source.basis_tree(), target, source)
1953
entry = state._get_entry(0, path_utf8='file1')
1954
self.assertEqual(sha1, entry[1][0][1])
1956
1944
def test_build_tree_accelerator_tree_missing_file(self):
1957
1945
source = self.create_ab_tree()
1958
1946
os.unlink('source/file1')
2116
2104
self.assertEqual('file.moved', target.id2path('lower-id'))
2117
2105
self.assertEqual('FILE', target.id2path('upper-id'))
2119
def test_build_tree_observes_sha(self):
2120
source = self.make_branch_and_tree('source')
2121
self.build_tree(['source/file1', 'source/dir/', 'source/dir/file2'])
2122
source.add(['file1', 'dir', 'dir/file2'],
2123
['file1-id', 'dir-id', 'file2-id'])
2124
source.commit('new files')
2125
target = self.make_branch_and_tree('target')
2127
self.addCleanup(target.unlock)
2128
# We make use of the fact that DirState caches its cutoff time. So we
2129
# set the 'safe' time to one minute in the future.
2130
state = target.current_dirstate()
2131
state._cutoff_time = time.time() + 60
2132
build_tree(source.basis_tree(), target)
2133
entry1_sha = osutils.sha_file_by_name('source/file1')
2134
entry2_sha = osutils.sha_file_by_name('source/dir/file2')
2135
# entry[1] is the state information, entry[1][0] is the state of the
2136
# working tree, entry[1][0][1] is the sha value for the current working
2138
entry1 = state._get_entry(0, path_utf8='file1')
2139
self.assertEqual(entry1_sha, entry1[1][0][1])
2140
# The 'size' field must also be set.
2141
self.assertEqual(25, entry1[1][0][2])
2142
entry1_state = entry1[1][0]
2143
entry2 = state._get_entry(0, path_utf8='dir/file2')
2144
self.assertEqual(entry2_sha, entry2[1][0][1])
2145
self.assertEqual(29, entry2[1][0][2])
2146
entry2_state = entry2[1][0]
2147
# Now, make sure that we don't have to re-read the content. The
2148
# packed_stat should match exactly.
2149
self.assertEqual(entry1_sha, target.get_file_sha1('file1-id', 'file1'))
2150
self.assertEqual(entry2_sha,
2151
target.get_file_sha1('file2-id', 'dir/file2'))
2152
self.assertEqual(entry1_state, entry1[1][0])
2153
self.assertEqual(entry2_state, entry2[1][0])
2156
2108
class TestCommitTransform(tests.TestCaseWithTransport):