142
144
def test_missing(self):
143
145
delta = TreeDelta()
144
delta.removed.append(TreeChange(b'git:a', ('a', 'a'), False, (True, True), (b'TREE_ROOT', b'TREE_ROOT'), ('a', 'a'), ('file', None), (True, False)))
145
changes = [((b'a', b'a'), (stat.S_IFREG | 0o755, 0),
146
(b'a' * 40, b'a' * 40))]
146
delta.removed.append(
148
b'git:a', ('a', 'a'), False, (True, True),
149
(b'TREE_ROOT', b'TREE_ROOT'), ('a', 'a'), ('file', None),
153
(b'a', stat.S_IFREG | 0o755, b'a' * 40),
154
(b'a', 0, b'a' * 40))]
147
155
self.assertEqual(
149
157
tree_delta_from_git_changes(changes, (default_mapping, default_mapping)))
184
193
t.add(b"a", stat.S_IFREG | 0o644, a.id)
185
194
self.expectDelta(
186
[((None, b''), (None, stat.S_IFDIR), (None, t.id)),
187
((None, b'a'), (None, stat.S_IFREG | 0o644), (None, a.id))])
195
[('add', (None, None, None), (b'', stat.S_IFDIR, t.id)),
196
('add', (None, None, None), (b'a', stat.S_IFREG | 0o644, a.id))])
198
def test_renamed_file(self):
199
self.build_tree(['a'])
201
self.wt.rename_one('a', 'b')
202
a = Blob.from_string(b'contents of a\n')
203
self.store.add_object(a)
205
oldt.add(b"a", stat.S_IFREG | 0o644, a.id)
206
self.store.add_object(oldt)
208
newt.add(b"b", stat.S_IFREG | 0o644, a.id)
209
self.store.add_object(newt)
211
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
212
('delete', (b'a', stat.S_IFREG | 0o644, a.id), (None, None, None)),
213
('add', (None, None, None), (b'b', stat.S_IFREG | 0o644, a.id)),
216
if dulwich_version >= (0, 19, 15):
218
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
219
('rename', (b'a', stat.S_IFREG | 0o644, a.id), (b'b', stat.S_IFREG | 0o644, a.id))],
220
tree_id=oldt.id, rename_detector=RenameDetector(self.store))
222
def test_copied_file(self):
223
self.build_tree(['a'])
225
self.wt.copy_one('a', 'b')
226
a = Blob.from_string(b'contents of a\n')
227
self.store.add_object(a)
229
oldt.add(b"a", stat.S_IFREG | 0o644, a.id)
230
self.store.add_object(oldt)
232
newt.add(b"a", stat.S_IFREG | 0o644, a.id)
233
newt.add(b"b", stat.S_IFREG | 0o644, a.id)
234
self.store.add_object(newt)
236
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
237
('add', (None, None, None), (b'b', stat.S_IFREG | 0o644, a.id)),
241
if dulwich_version >= (0, 19, 15):
243
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
244
('copy', (b'a', stat.S_IFREG | 0o644, a.id), (b'b', stat.S_IFREG | 0o644, a.id))],
245
tree_id=oldt.id, rename_detector=RenameDetector(self.store, find_copies_harder=True))
247
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
248
('add', (None, None, None), (b'b', stat.S_IFREG | 0o644, a.id)),
250
tree_id=oldt.id, rename_detector=RenameDetector(self.store, find_copies_harder=False))
189
252
def test_added_unknown_file(self):
190
253
self.build_tree(['a'])
192
255
self.expectDelta(
193
[((None, b''), (None, stat.S_IFDIR), (None, t.id))])
256
[('add', (None, None, None), (b'', stat.S_IFDIR, t.id))])
194
257
a = Blob.from_string(b'contents of a\n')
196
259
t.add(b"a", stat.S_IFREG | 0o644, a.id)
197
260
self.expectDelta(
198
[((None, b''), (None, stat.S_IFDIR), (None, t.id)),
199
((None, b'a'), (None, stat.S_IFREG | 0o644), (None, a.id))],
261
[('add', (None, None, None), (b'', stat.S_IFDIR, t.id)),
262
('add', (None, None, None), (b'a', stat.S_IFREG | 0o644, a.id))],
201
264
want_unversioned=True)
240
307
newt.add(b"a", stat.S_IFDIR, newa.id)
241
308
self.expectDelta([
243
(stat.S_IFDIR, stat.S_IFDIR),
245
((b'a', b'a'), (stat.S_IFREG | 0o644, stat.S_IFDIR), (olda.id, newa.id))
310
(b'', stat.S_IFDIR, oldt.id),
311
(b'', stat.S_IFDIR, newt.id)),
313
(b'a', stat.S_IFREG | 0o644, olda.id),
314
(b'a', stat.S_IFDIR, newa.id))
246
315
], want_unversioned=False)
247
316
self.expectDelta([
249
(stat.S_IFDIR, stat.S_IFDIR),
251
((b'a', b'a'), (stat.S_IFREG | 0o644, stat.S_IFDIR), (olda.id, newa.id))
318
(b'', stat.S_IFDIR, oldt.id),
319
(b'', stat.S_IFDIR, newt.id)),
321
(b'a', stat.S_IFREG | 0o644, olda.id),
322
(b'a', stat.S_IFDIR, newa.id)),
252
323
], want_unversioned=True)
254
325
def test_extra(self):