248
248
tree2 = self.make_to_branch_and_tree('2')
249
249
tree1 = self.get_tree_no_parents_no_content(tree1)
250
250
tree2 = self.get_to_tree_no_parents_no_content(tree2)
252
self.addCleanup(tree1.unlock)
254
self.addCleanup(tree2.unlock)
251
255
self.assertEqual([], list(tree2._iter_changes(tree1)))
253
257
def added(self, tree, file_id):
270
274
tree1 = self.get_tree_no_parents_no_content(tree1)
271
275
tree2 = self.get_to_tree_no_parents_abc_content(tree2)
278
self.addCleanup(tree1.unlock)
280
self.addCleanup(tree2.unlock)
273
281
self.assertEqual([self.added(tree2, 'root-id'),
274
282
self.added(tree2, 'a-id'),
275
283
self.added(tree2, 'b-id'),
282
290
tree2 = self.make_to_branch_and_tree('2')
283
291
tree1 = self.get_tree_no_parents_no_content(tree1)
284
292
tree2 = self.get_to_tree_no_parents_abc_content(tree2)
294
self.addCleanup(tree1.unlock)
296
self.addCleanup(tree2.unlock)
285
297
self.assertEqual([self.added(tree2, 'a-id')],
286
298
list(tree2._iter_changes(tree1,
287
299
specific_file_ids=['a-id'])))
294
306
tree2 = self.make_to_branch_and_tree('2')
295
307
tree1 = self.get_tree_no_parents_no_content(tree1)
296
308
tree2 = self.get_to_tree_no_parents_abc_content(tree2)
310
self.addCleanup(tree1.unlock)
312
self.addCleanup(tree2.unlock)
297
313
self.assertEqual([self.added(tree2, 'a-id'),
298
314
self.added(tree2, 'c-id')],
299
315
list(tree2._iter_changes(tree1,
314
330
(entry.parent_id, None),
315
331
(entry.name, None), (entry.kind, None),
316
332
(entry.executable, None))
334
self.addCleanup(tree1.unlock)
336
self.addCleanup(tree2.unlock)
317
337
self.assertEqual([self.added(tree1, 'empty-root-id'),
318
338
deleted('root-id'), deleted('a-id'),
319
339
deleted('b-id'), deleted('c-id')],
325
345
tree1 = self.get_tree_no_parents_abc_content(tree1)
326
346
tree2 = self.get_to_tree_no_parents_abc_content_2(tree2)
327
347
root_id = tree1.inventory.root.file_id
349
self.addCleanup(tree1.unlock)
351
self.addCleanup(tree2.unlock)
328
352
self.assertEqual([('a-id', 'a', True, (True, True),
329
353
(root_id, root_id), ('a', 'a'),
330
354
('file', 'file'), (False, False))],
335
359
tree2 = self.make_to_branch_and_tree('2')
336
360
tree1 = self.get_tree_no_parents_abc_content(tree1)
337
361
tree2 = self.get_to_tree_no_parents_abc_content_3(tree2)
363
self.addCleanup(tree1.unlock)
365
self.addCleanup(tree2.unlock)
338
366
self.assertEqual([('c-id', 'b/c', False, (True, True),
339
367
('b-id', 'b-id'), ('c', 'c'), ('file', 'file'),
340
368
(False, True))], list(tree2._iter_changes(tree1)))
345
373
tree1 = self.get_tree_no_parents_abc_content(tree1)
346
374
tree2 = self.get_to_tree_no_parents_abc_content_4(tree2)
347
375
root_id = tree1.inventory.root.file_id
377
self.addCleanup(tree1.unlock)
379
self.addCleanup(tree2.unlock)
348
380
self.assertEqual([('a-id', 'd', False, (True, True),
349
381
(root_id, root_id), ('a', 'd'), ('file', 'file'),
350
382
(False, False))], list(tree2._iter_changes(tree1)))
355
387
tree1 = self.get_tree_no_parents_abc_content(tree1)
356
388
tree2 = self.get_to_tree_no_parents_abc_content_5(tree2)
357
389
root_id = tree1.inventory.root.file_id
391
self.addCleanup(tree1.unlock)
393
self.addCleanup(tree2.unlock)
358
394
self.assertEqual([('a-id', 'd', True, (True, True),
359
395
(root_id, root_id), ('a', 'd'), ('file', 'file'),
360
396
(False, False))], list(tree2._iter_changes(tree1)))
365
401
tree1 = self.get_tree_no_parents_abc_content(tree1)
366
402
tree2 = self.get_to_tree_no_parents_abc_content_6(tree2)
367
403
root_id = tree1.inventory.root.file_id
405
self.addCleanup(tree1.unlock)
407
self.addCleanup(tree2.unlock)
368
408
self.assertEqual([('c-id', 'e', False, (True, True),
369
409
('b-id', root_id), ('c', 'e'), ('file', 'file'),
370
410
(False, True))], list(tree2._iter_changes(tree1)))
376
416
tree1 = self.get_tree_no_parents_abc_content(tree1)
377
417
tree2 = self.get_to_tree_no_parents_abc_content_5(tree2)
378
418
root_id = tree1.inventory.root.file_id
420
self.addCleanup(tree1.unlock)
422
self.addCleanup(tree2.unlock)
379
423
def unchanged(file_id):
380
424
entry = tree1.inventory[file_id]
381
425
parent = entry.parent_id
382
426
name = entry.name
383
427
kind = entry.kind
384
428
executable = entry.executable
385
return (file_id, tree1.id2path(file_id), False, (True, True),
386
(parent, parent), (name, name), (kind, kind),
429
return (file_id, tree1.id2path(file_id), False, (True, True),
430
(parent, parent), (name, name), (kind, kind),
387
431
(executable, executable))
388
432
self.assertEqual([unchanged(root_id), unchanged('b-id'),
389
('a-id', 'd', True, (True, True),
433
('a-id', 'd', True, (True, True),
390
434
(root_id, root_id), ('a', 'd'), ('file', 'file'),
391
435
(False, False)), unchanged('c-id')],
392
list(tree2._iter_changes(tree1,
436
list(tree2._iter_changes(tree1,
393
437
include_unchanged=True)))
395
439
def test_compare_subtrees(self):
398
442
tree1.set_root_id('root-id')
399
443
subtree1 = self.make_branch_and_tree('1/sub')
400
444
subtree1.set_root_id('subtree-id')
401
tree1.add_reference(subtree1)
446
tree1.add_reference(subtree1)
447
except errors.UnsupportedOperation:
448
self.assertIsInstance(tree1, workingtree_4.WorkingTree4)
449
raise tests.TestSkipped('Tree does not support references')
403
451
tree2 = self.make_to_branch_and_tree('2')
404
452
tree2.set_root_id('root-id')