66
65
self.link_1 = self.inv_1['linkid']
67
66
self.link_2 = get_entry(self.tree_2, 'linkid')
69
def test_file_diff_deleted(self):
71
self.applyDeprecated(one_zero,
74
"old_label", self.tree_1,
75
"/dev/null", None, None,
77
self.assertEqual(output.getvalue(), "--- old_label\n"
83
def test_file_diff_added(self):
85
self.applyDeprecated(one_zero,
88
"new_label", self.tree_1,
89
"/dev/null", None, None,
91
self.assertEqual(output.getvalue(), "--- /dev/null\n"
97
def test_file_diff_changed(self):
99
self.applyDeprecated(one_zero,
102
"/dev/null", self.tree_1,
103
"new_label", self.file_2, self.tree_2,
105
self.assertEqual(output.getvalue(), "--- /dev/null\n"
112
def test_file_diff_binary(self):
114
self.applyDeprecated(one_zero,
117
"/dev/null", self.tree_1,
118
"new_label", self.file_2b, self.tree_2,
120
self.assertEqual(output.getvalue(),
121
"Binary files /dev/null and new_label differ\n")
123
def test_link_diff_deleted(self):
124
self.requireFeature(SymlinkFeature)
126
self.applyDeprecated(one_zero,
128
internal_diff, "old_label",
129
self.tree_1, "/dev/null", None, None,
131
self.assertEqual(output.getvalue(),
132
"=== target was 'target1'\n")
134
def test_link_diff_added(self):
135
self.requireFeature(SymlinkFeature)
137
self.applyDeprecated(one_zero,
140
"new_label", self.tree_1,
141
"/dev/null", None, None,
142
output, reverse=True)
143
self.assertEqual(output.getvalue(),
144
"=== target is 'target1'\n")
146
def test_link_diff_changed(self):
147
self.requireFeature(SymlinkFeature)
149
self.applyDeprecated(one_zero,
152
"/dev/null", self.tree_1,
153
"new_label", self.link_2, self.tree_2,
155
self.assertEqual(output.getvalue(),
156
"=== target changed 'target1' => 'target2'\n")
159
69
class TestPreviousHeads(TestCaseWithTree):
190
100
self.weave = self.branch.repository.weave_store.get_weave('fileid',
191
101
self.branch.repository.get_transaction())
193
def get_previous_heads(self, inventories):
194
return self.applyDeprecated(zero_ninetyone,
195
self.file_active.find_previous_heads,
197
self.branch.repository.weave_store,
198
self.branch.repository.get_transaction())
200
def test_fileid_in_no_inventory(self):
201
self.assertEqual({}, self.get_previous_heads([self.inv_A]))
203
def test_fileid_in_one_inventory(self):
204
self.assertEqual({'B':self.inv_B['fileid']},
205
self.get_previous_heads([self.inv_B]))
206
self.assertEqual({'B':self.inv_B['fileid']},
207
self.get_previous_heads([self.inv_A, self.inv_B]))
208
self.assertEqual({'B':self.inv_B['fileid']},
209
self.get_previous_heads([self.inv_B, self.inv_A]))
211
def test_fileid_in_two_inventories_gives_both_entries(self):
212
self.assertEqual({'B':self.inv_B['fileid'],
213
'C':self.inv_C['fileid']},
214
self.get_previous_heads([self.inv_B, self.inv_C]))
215
self.assertEqual({'B':self.inv_B['fileid'],
216
'C':self.inv_C['fileid']},
217
self.get_previous_heads([self.inv_C, self.inv_B]))
219
def test_fileid_in_two_inventories_already_merged_gives_head(self):
220
self.assertEqual({'D':self.inv_D['fileid']},
221
self.get_previous_heads([self.inv_B, self.inv_D]))
222
self.assertEqual({'D':self.inv_D['fileid']},
223
self.get_previous_heads([self.inv_D, self.inv_B]))
225
103
# TODO: test two inventories with the same file revision