64
64
tree2.set_root_id(tree1.get_root_id())
65
65
tree1 = self.get_tree_no_parents_no_content(tree1)
66
66
tree2 = self.get_tree_no_parents_abc_content(tree2)
67
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
67
tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
68
68
d = self.intertree_class(tree1, tree2).compare()
69
69
self.assertEqual([('a', 'a-id', 'file'),
70
70
('b', 'b-id', 'directory'),
125
125
tree2.set_root_id(tree1.get_root_id())
126
126
tree1 = self.get_tree_no_parents_abc_content(tree1)
127
127
tree2 = self.get_tree_no_parents_abc_content_2(tree2)
128
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
128
tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
129
129
d = self.intertree_class(tree1, tree2).compare()
130
130
self.assertEqual([], d.added)
131
131
self.assertEqual([('a', 'a-id', 'file', True, False)], d.modified)
139
139
tree2.set_root_id(tree1.get_root_id())
140
140
tree1 = self.get_tree_no_parents_abc_content(tree1)
141
141
tree2 = self.get_tree_no_parents_abc_content_3(tree2)
142
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
142
tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
143
143
d = self.intertree_class(tree1, tree2).compare()
144
144
self.assertEqual([], d.added)
145
145
self.assertEqual([('b/c', 'c-id', 'file', False, True)], d.modified)
195
195
tree2.set_root_id(tree1.get_root_id())
196
196
tree1 = self.get_tree_no_parents_no_content(tree1)
197
197
tree2 = self.get_tree_no_parents_abc_content(tree2)
198
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
198
tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
199
199
d = self.intertree_class(tree1, tree2).compare(specific_files=['a'])
200
200
self.assertEqual([('a', 'a-id', 'file')], d.added)
201
201
self.assertEqual([], d.modified)
225
225
tree2 = self.make_to_branch_and_tree('2')
226
226
tree1 = self.get_tree_no_parents_no_content(tree1)
227
227
tree2 = self.get_tree_no_parents_abc_content(tree2)
228
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
228
tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
229
229
d = self.intertree_class(tree1, tree2).compare(specific_files=['b'])
230
230
self.assertEqual(
231
231
[('b', 'b-id', 'directory'),('b/c', 'c-id', 'file')],
307
307
tree1.add(['a', 'c'], ['a-id', 'c-id'])
308
308
tree2.add(['a', 'c'], ['a-id', 'c-id'])
310
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
310
tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
311
311
d = self.intertree_class(tree1, tree2).compare()
312
312
self.assertEqual([], d.added)
313
313
self.assertEqual([(u'a', 'a-id', 'file', True, False),
429
429
tree2 = self.make_to_branch_and_tree('2')
430
430
tree1 = self.get_tree_no_parents_no_content(tree1)
431
431
tree2 = self.get_tree_no_parents_no_content(tree2)
432
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
432
tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
433
433
self.assertEqual([], self.do_iter_changes(tree1, tree2))
435
435
def added(self, tree, file_id):
436
entry = tree.inventory[file_id]
437
path = tree.id2path(file_id)
436
path, entry = self.get_path_entry(tree, file_id)
438
437
return (file_id, (None, path), True, (False, True), (None, entry.parent_id),
439
438
(None, entry.name), (None, entry.kind),
440
439
(None, entry.executable))
442
def get_path_entry(tree, file_id):
443
iterator = tree.iter_entries_by_dir(specific_file_ids=[file_id])
444
return iterator.next()
442
446
def content_changed(self, tree, file_id):
443
entry = tree.inventory[file_id]
444
path = tree.id2path(file_id)
445
return (file_id, (path, path), True, (True, True), (entry.parent_id, entry.parent_id),
447
path, entry = self.get_path_entry(tree, file_id)
448
return (file_id, (path, path), True, (True, True),
449
(entry.parent_id, entry.parent_id),
446
450
(entry.name, entry.name), (entry.kind, entry.kind),
447
451
(entry.executable, entry.executable))
449
453
def kind_changed(self, from_tree, to_tree, file_id):
450
old_entry = from_tree.inventory[file_id]
451
new_entry = to_tree.inventory[file_id]
452
path = to_tree.id2path(file_id)
453
from_path = from_tree.id2path(file_id)
454
return (file_id, (from_path, path), True, (True, True), (old_entry.parent_id, new_entry.parent_id),
455
(old_entry.name, new_entry.name), (old_entry.kind, new_entry.kind),
454
from_path, old_entry = self.get_path_entry(from_tree, file_id)
455
path, new_entry = self.get_path_entry(to_tree, file_id)
456
return (file_id, (from_path, path), True, (True, True),
457
(old_entry.parent_id, new_entry.parent_id),
458
(old_entry.name, new_entry.name),
459
(old_entry.kind, new_entry.kind),
456
460
(old_entry.executable, new_entry.executable))
458
462
def missing(self, file_id, from_path, to_path, parent_id, kind):
471
475
(entry.executable, None))
473
477
def renamed(self, from_tree, to_tree, file_id, content_changed):
474
from_entry = from_tree.inventory[file_id]
475
to_entry = to_tree.inventory[file_id]
476
from_path = from_tree.id2path(file_id)
477
to_path = to_tree.id2path(file_id)
478
from_path, from_entry = self.get_path_entry(from_tree, file_id)
479
to_path, to_entry = self.get_path_entry(to_tree, file_id)
478
480
return (file_id, (from_path, to_path), content_changed, (True, True),
479
481
(from_entry.parent_id, to_entry.parent_id),
480
482
(from_entry.name, to_entry.name),
482
484
(from_entry.executable, to_entry.executable))
484
486
def unchanged(self, tree, file_id):
485
entry = tree.inventory[file_id]
487
path, entry = self.get_path_entry(tree, file_id)
486
488
parent = entry.parent_id
487
489
name = entry.name
488
490
kind = entry.kind
489
491
executable = entry.executable
490
path = tree.id2path(file_id)
491
492
return (file_id, (path, path), False, (True, True),
492
493
(parent, parent), (name, name), (kind, kind),
493
494
(executable, executable))
495
496
def unversioned(self, tree, path):
496
497
"""Create an unversioned result."""
497
498
_, basename = os.path.split(path)
498
kind = file_kind(tree.abspath(path))
499
kind = tree._comparison_data(None, path)[0]
499
500
return (None, (None, path), True, (False, False), (None, None),
500
501
(None, basename), (None, kind),
593
594
tree2 = self.make_to_branch_and_tree('2')
594
595
tree1 = self.get_tree_no_parents_abc_content(tree1)
595
596
tree2 = self.get_tree_no_parents_abc_content_2(tree2)
596
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
597
tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
597
598
root_id = tree1.path2id('')
598
599
self.assertEqual([('a-id', ('a', 'a'), True, (True, True),
599
600
(root_id, root_id), ('a', 'a'),
605
606
tree2 = self.make_to_branch_and_tree('2')
606
607
tree1 = self.get_tree_no_parents_abc_content(tree1)
607
608
tree2 = self.get_tree_no_parents_abc_content_3(tree2)
608
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
609
tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
609
610
self.assertEqual([('c-id', ('b/c', 'b/c'), False, (True, True),
610
611
('b-id', 'b-id'), ('c', 'c'), ('file', 'file'),
630
631
tree2 = self.make_to_branch_and_tree('2')
631
632
tree1 = self.get_tree_no_parents_abc_content(tree1)
632
633
tree2 = self.get_tree_no_parents_abc_content_4(tree2)
633
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
634
tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
634
635
root_id = tree1.path2id('')
635
636
self.assertEqual([('a-id', ('a', 'd'), False, (True, True),
636
637
(root_id, root_id), ('a', 'd'), ('file', 'file'),
642
643
tree2 = self.make_to_branch_and_tree('2')
643
644
tree1 = self.get_tree_no_parents_abc_content(tree1)
644
645
tree2 = self.get_tree_no_parents_abc_content_5(tree2)
645
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
646
tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
646
647
root_id = tree1.path2id('')
647
648
self.assertEqual([('a-id', ('a', 'd'), True, (True, True),
648
649
(root_id, root_id), ('a', 'd'), ('file', 'file'),
654
655
tree2 = self.make_to_branch_and_tree('2')
655
656
tree1 = self.get_tree_no_parents_abc_content(tree1)
656
657
tree2 = self.get_tree_no_parents_abc_content_6(tree2)
657
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
658
tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
658
659
root_id = tree1.path2id('')
659
660
self.assertEqual([('c-id', ('b/c', 'e'), False, (True, True),
660
661
('b-id', root_id), ('c', 'e'), ('file', 'file'),