140
142
def test_missing(self):
141
143
delta = TreeDelta()
142
delta.removed.append(TreeChange(b'git:a', ('a', 'a'), False, (True, True), (b'TREE_ROOT', b'TREE_ROOT'), ('a', 'a'), ('file', None), (True, False)))
143
changes = [((b'a', b'a'), (stat.S_IFREG | 0o755, 0),
144
(b'a' * 40, b'a' * 40))]
144
delta.removed.append(
146
b'git:a', ('a', 'a'), False, (True, True),
147
(b'TREE_ROOT', b'TREE_ROOT'), ('a', 'a'), ('file', None),
151
(b'a', stat.S_IFREG | 0o755, b'a' * 40),
152
(b'a', 0, b'a' * 40))]
145
153
self.assertEqual(
147
155
tree_delta_from_git_changes(changes, (default_mapping, default_mapping)))
182
191
t.add(b"a", stat.S_IFREG | 0o644, a.id)
183
192
self.expectDelta(
184
[((None, b''), (None, stat.S_IFDIR), (None, t.id)),
185
((None, b'a'), (None, stat.S_IFREG | 0o644), (None, a.id))])
193
[('add', (None, None, None), (b'', stat.S_IFDIR, t.id)),
194
('add', (None, None, None), (b'a', stat.S_IFREG | 0o644, a.id))])
196
def test_renamed_file(self):
197
self.build_tree(['a'])
199
self.wt.rename_one('a', 'b')
200
a = Blob.from_string(b'contents of a\n')
201
self.store.add_object(a)
203
oldt.add(b"a", stat.S_IFREG | 0o644, a.id)
204
self.store.add_object(oldt)
206
newt.add(b"b", stat.S_IFREG | 0o644, a.id)
207
self.store.add_object(newt)
209
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
210
('delete', (b'a', stat.S_IFREG | 0o644, a.id), (None, None, None)),
211
('add', (None, None, None), (b'b', stat.S_IFREG | 0o644, a.id)),
214
if dulwich_version >= (0, 19, 15):
216
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
217
('rename', (b'a', stat.S_IFREG | 0o644, a.id), (b'b', stat.S_IFREG | 0o644, a.id))],
218
tree_id=oldt.id, rename_detector=RenameDetector(self.store))
220
def test_copied_file(self):
221
self.build_tree(['a'])
223
self.wt.copy_one('a', 'b')
224
a = Blob.from_string(b'contents of a\n')
225
self.store.add_object(a)
227
oldt.add(b"a", stat.S_IFREG | 0o644, a.id)
228
self.store.add_object(oldt)
230
newt.add(b"a", stat.S_IFREG | 0o644, a.id)
231
newt.add(b"b", stat.S_IFREG | 0o644, a.id)
232
self.store.add_object(newt)
234
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
235
('add', (None, None, None), (b'b', stat.S_IFREG | 0o644, a.id)),
239
if dulwich_version >= (0, 19, 15):
241
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
242
('copy', (b'a', stat.S_IFREG | 0o644, a.id), (b'b', stat.S_IFREG | 0o644, a.id))],
243
tree_id=oldt.id, rename_detector=RenameDetector(self.store, find_copies_harder=True))
245
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
246
('add', (None, None, None), (b'b', stat.S_IFREG | 0o644, a.id)),
248
tree_id=oldt.id, rename_detector=RenameDetector(self.store, find_copies_harder=False))
187
250
def test_added_unknown_file(self):
188
251
self.build_tree(['a'])
190
253
self.expectDelta(
191
[((None, b''), (None, stat.S_IFDIR), (None, t.id))])
254
[('add', (None, None, None), (b'', stat.S_IFDIR, t.id))])
192
255
a = Blob.from_string(b'contents of a\n')
194
257
t.add(b"a", stat.S_IFREG | 0o644, a.id)
195
258
self.expectDelta(
196
[((None, b''), (None, stat.S_IFDIR), (None, t.id)),
197
((None, b'a'), (None, stat.S_IFREG | 0o644), (None, a.id))],
259
[('add', (None, None, None), (b'', stat.S_IFDIR, t.id)),
260
('add', (None, None, None), (b'a', stat.S_IFREG | 0o644, a.id))],
199
262
want_unversioned=True)
238
305
newt.add(b"a", stat.S_IFDIR, newa.id)
239
306
self.expectDelta([
241
(stat.S_IFDIR, stat.S_IFDIR),
243
((b'a', b'a'), (stat.S_IFREG | 0o644, stat.S_IFDIR), (olda.id, newa.id))
308
(b'', stat.S_IFDIR, oldt.id),
309
(b'', stat.S_IFDIR, newt.id)),
311
(b'a', stat.S_IFREG | 0o644, olda.id),
312
(b'a', stat.S_IFDIR, newa.id))
244
313
], want_unversioned=False)
245
314
self.expectDelta([
247
(stat.S_IFDIR, stat.S_IFDIR),
249
((b'a', b'a'), (stat.S_IFREG | 0o644, stat.S_IFDIR), (olda.id, newa.id))
316
(b'', stat.S_IFDIR, oldt.id),
317
(b'', stat.S_IFDIR, newt.id)),
319
(b'a', stat.S_IFREG | 0o644, olda.id),
320
(b'a', stat.S_IFDIR, newa.id)),
250
321
], want_unversioned=True)
252
323
def test_extra(self):