272
315
tree1 = self.make_branch_and_tree('1')
273
316
tree2 = self.make_to_branch_and_tree('2')
274
317
tree1 = self.get_tree_no_parents_no_content(tree1)
275
tree2 = self.get_to_tree_no_parents_abc_content(tree2)
318
tree2 = self.get_tree_no_parents_abc_content(tree2)
319
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
277
320
tree1.lock_read()
278
self.addCleanup(tree1.unlock)
279
321
tree2.lock_read()
280
self.addCleanup(tree2.unlock)
281
self.assertEqual([self.added(tree2, 'root-id'),
282
self.added(tree2, 'a-id'),
283
self.added(tree2, 'b-id'),
284
self.added(tree2, 'c-id'),
285
self.deleted(tree1, 'empty-root-id')],
286
list(tree2._iter_changes(tree1)))
323
self.added(tree2, 'root-id'),
324
self.added(tree2, 'a-id'),
325
self.added(tree2, 'b-id'),
326
self.added(tree2, 'c-id'),
327
self.deleted(tree1, 'empty-root-id')]
330
self.assertEqual(expected_results, self.do_iter_changes(tree1, tree2))
288
332
def test_empty_to_abc_content_a_only(self):
289
333
tree1 = self.make_branch_and_tree('1')
290
334
tree2 = self.make_to_branch_and_tree('2')
291
335
tree1 = self.get_tree_no_parents_no_content(tree1)
292
tree2 = self.get_to_tree_no_parents_abc_content(tree2)
294
self.addCleanup(tree1.unlock)
296
self.addCleanup(tree2.unlock)
297
self.assertEqual([self.added(tree2, 'a-id')],
298
list(tree2._iter_changes(tree1,
299
specific_file_ids=['a-id'])))
300
self.assertEqual([self.deleted(tree2, 'a-id')],
301
list(tree1._iter_changes(tree2,
302
specific_file_ids=['a-id'])))
336
tree2 = self.get_tree_no_parents_abc_content(tree2)
337
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
341
[self.added(tree2, 'a-id')],
342
self.do_iter_changes(tree1, tree2, specific_file_ids=['a-id']))
346
def test_abc_content_to_empty_to_abc_content_a_only(self):
347
tree1 = self.make_branch_and_tree('1')
348
tree2 = self.make_to_branch_and_tree('2')
349
tree1 = self.get_tree_no_parents_abc_content(tree1)
350
tree2 = self.get_tree_no_parents_no_content(tree2)
351
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
355
[self.deleted(tree1, 'a-id')],
356
self.do_iter_changes(tree1, tree2, specific_file_ids=['a-id']))
304
360
def test_empty_to_abc_content_a_and_c_only(self):
305
361
tree1 = self.make_branch_and_tree('1')
306
362
tree2 = self.make_to_branch_and_tree('2')
307
363
tree1 = self.get_tree_no_parents_no_content(tree1)
308
tree2 = self.get_to_tree_no_parents_abc_content(tree2)
364
tree2 = self.get_tree_no_parents_abc_content(tree2)
365
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
309
366
tree1.lock_read()
310
self.addCleanup(tree1.unlock)
311
367
tree2.lock_read()
312
self.addCleanup(tree2.unlock)
313
self.assertEqual([self.added(tree2, 'a-id'),
314
self.added(tree2, 'c-id')],
315
list(tree2._iter_changes(tree1,
316
specific_file_ids=['a-id',
318
d = self.intertree_class(tree1, tree2).compare(
319
specific_files=['a', 'b/c'])
368
expected_result = [self.added(tree2, 'a-id'), self.added(tree2, 'c-id')]
371
self.assertEqual(expected_result,
372
self.do_iter_changes(tree1, tree2, specific_file_ids=['a-id', 'c-id']))
321
def test_abc_content(self):
374
def test_abc_content_to_empty(self):
322
375
tree1 = self.make_branch_and_tree('1')
323
376
tree2 = self.make_to_branch_and_tree('2')
324
tree1 = self.get_tree_no_parents_no_content(tree1)
325
tree2 = self.get_to_tree_no_parents_abc_content(tree2)
377
tree1 = self.get_tree_no_parents_abc_content(tree1)
378
tree2 = self.get_tree_no_parents_no_content(tree2)
379
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
326
382
def deleted(file_id):
327
entry = tree2.inventory[file_id]
328
path = tree2.id2path(file_id)
329
return (file_id, path, True, (True, False),
383
entry = tree1.inventory[file_id]
384
path = tree1.id2path(file_id)
385
return (file_id, path, True, (True, False),
330
386
(entry.parent_id, None),
331
(entry.name, None), (entry.kind, None),
387
(entry.name, None), (entry.kind, None),
332
388
(entry.executable, None))
334
self.addCleanup(tree1.unlock)
336
self.addCleanup(tree2.unlock)
337
self.assertEqual([self.added(tree1, 'empty-root-id'),
338
deleted('root-id'), deleted('a-id'),
339
deleted('b-id'), deleted('c-id')],
340
list(tree1._iter_changes(tree2)))
389
expected_results = [self.added(tree2, 'empty-root-id'),
390
deleted('root-id'), deleted('a-id'),
391
deleted('b-id'), deleted('c-id')]
396
self.do_iter_changes(tree1, tree2))
342
398
def test_content_modification(self):
343
399
tree1 = self.make_branch_and_tree('1')
344
400
tree2 = self.make_to_branch_and_tree('2')
345
401
tree1 = self.get_tree_no_parents_abc_content(tree1)
346
tree2 = self.get_to_tree_no_parents_abc_content_2(tree2)
347
root_id = tree1.inventory.root.file_id
349
self.addCleanup(tree1.unlock)
351
self.addCleanup(tree2.unlock)
352
self.assertEqual([('a-id', 'a', True, (True, True),
353
(root_id, root_id), ('a', 'a'),
354
('file', 'file'), (False, False))],
355
list(tree2._iter_changes(tree1)))
402
tree2 = self.get_tree_no_parents_abc_content_2(tree2)
403
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
404
root_id = tree1.path2id('')
405
self.assertEqual([('a-id', 'a', True, (True, True),
406
(root_id, root_id), ('a', 'a'),
407
('file', 'file'), (False, False))],
408
self.do_iter_changes(tree1, tree2))
357
410
def test_meta_modification(self):
358
411
tree1 = self.make_branch_and_tree('1')
359
412
tree2 = self.make_to_branch_and_tree('2')
360
413
tree1 = self.get_tree_no_parents_abc_content(tree1)
361
tree2 = self.get_to_tree_no_parents_abc_content_3(tree2)
363
self.addCleanup(tree1.unlock)
365
self.addCleanup(tree2.unlock)
366
self.assertEqual([('c-id', 'b/c', False, (True, True),
367
('b-id', 'b-id'), ('c', 'c'), ('file', 'file'),
368
(False, True))], list(tree2._iter_changes(tree1)))
414
tree2 = self.get_tree_no_parents_abc_content_3(tree2)
415
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
416
self.assertEqual([('c-id', 'b/c', False, (True, True),
417
('b-id', 'b-id'), ('c', 'c'), ('file', 'file'),
419
self.do_iter_changes(tree1, tree2))
370
421
def test_file_rename(self):
371
422
tree1 = self.make_branch_and_tree('1')
372
423
tree2 = self.make_to_branch_and_tree('2')
373
424
tree1 = self.get_tree_no_parents_abc_content(tree1)
374
tree2 = self.get_to_tree_no_parents_abc_content_4(tree2)
375
root_id = tree1.inventory.root.file_id
377
self.addCleanup(tree1.unlock)
379
self.addCleanup(tree2.unlock)
380
self.assertEqual([('a-id', 'd', False, (True, True),
425
tree2 = self.get_tree_no_parents_abc_content_4(tree2)
426
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
427
root_id = tree1.path2id('')
428
self.assertEqual([('a-id', 'd', False, (True, True),
381
429
(root_id, root_id), ('a', 'd'), ('file', 'file'),
382
(False, False))], list(tree2._iter_changes(tree1)))
431
self.do_iter_changes(tree1, tree2))
384
433
def test_file_rename_and_modification(self):
385
434
tree1 = self.make_branch_and_tree('1')
386
435
tree2 = self.make_to_branch_and_tree('2')
387
436
tree1 = self.get_tree_no_parents_abc_content(tree1)
388
tree2 = self.get_to_tree_no_parents_abc_content_5(tree2)
389
root_id = tree1.inventory.root.file_id
391
self.addCleanup(tree1.unlock)
393
self.addCleanup(tree2.unlock)
394
self.assertEqual([('a-id', 'd', True, (True, True),
437
tree2 = self.get_tree_no_parents_abc_content_5(tree2)
438
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
439
root_id = tree1.path2id('')
440
self.assertEqual([('a-id', 'd', True, (True, True),
395
441
(root_id, root_id), ('a', 'd'), ('file', 'file'),
396
(False, False))], list(tree2._iter_changes(tree1)))
443
self.do_iter_changes(tree1, tree2))
398
445
def test_file_rename_and_meta_modification(self):
399
446
tree1 = self.make_branch_and_tree('1')
400
447
tree2 = self.make_to_branch_and_tree('2')
401
448
tree1 = self.get_tree_no_parents_abc_content(tree1)
402
tree2 = self.get_to_tree_no_parents_abc_content_6(tree2)
403
root_id = tree1.inventory.root.file_id
405
self.addCleanup(tree1.unlock)
407
self.addCleanup(tree2.unlock)
408
self.assertEqual([('c-id', 'e', False, (True, True),
409
('b-id', root_id), ('c', 'e'), ('file', 'file'),
410
(False, True))], list(tree2._iter_changes(tree1)))
449
tree2 = self.get_tree_no_parents_abc_content_6(tree2)
450
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
451
root_id = tree1.path2id('')
452
self.assertEqual([('c-id', 'e', False, (True, True),
453
('b-id', root_id), ('c', 'e'), ('file', 'file'),
455
self.do_iter_changes(tree1, tree2))
412
457
def test_unchanged_with_renames_and_modifications(self):
413
458
"""want_unchanged should generate a list of unchanged entries."""
414
459
tree1 = self.make_branch_and_tree('1')
415
460
tree2 = self.make_to_branch_and_tree('2')
416
461
tree1 = self.get_tree_no_parents_abc_content(tree1)
417
tree2 = self.get_to_tree_no_parents_abc_content_5(tree2)
418
root_id = tree1.inventory.root.file_id
462
tree2 = self.get_tree_no_parents_abc_content_5(tree2)
463
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
464
root_id = tree1.path2id('')
419
465
tree1.lock_read()
420
466
self.addCleanup(tree1.unlock)
421
467
tree2.lock_read()