298
296
specific_files=['d'],
299
297
require_versioned=True)
299
def test_default_ignores_unversioned_files(self):
300
tree1 = self.make_branch_and_tree('tree1')
301
tree2 = self.make_to_branch_and_tree('tree2')
302
self.build_tree(['tree1/a', 'tree1/c',
303
'tree2/a', 'tree2/b', 'tree2/c'])
304
tree1.add(['a', 'c'], ['a-id', 'c-id'])
305
tree2.add(['a', 'c'], ['a-id', 'c-id'])
307
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
308
d = self.intertree_class(tree1, tree2).compare()
309
self.assertEqual([], d.added)
310
self.assertEqual([(u'a', 'a-id', 'file', True, False),
311
(u'c', 'c-id', 'file', True, False)], d.modified)
312
self.assertEqual([], d.removed)
313
self.assertEqual([], d.renamed)
314
self.assertEqual([], d.unchanged)
315
self.assertEqual([], d.unversioned)
317
def test_unversioned_paths_in_tree(self):
318
tree1 = self.make_branch_and_tree('tree1')
319
tree2 = self.make_to_branch_and_tree('tree2')
320
self.build_tree(['tree2/file', 'tree2/dir/'])
322
os.symlink('target', 'tree2/link')
323
links_supported = True
325
# links_supported = False
326
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
327
d = self.intertree_class(tree1, tree2).compare(want_unversioned=True)
328
self.assertEqual([], d.added)
329
self.assertEqual([], d.modified)
330
self.assertEqual([], d.removed)
331
self.assertEqual([], d.renamed)
332
self.assertEqual([], d.unchanged)
333
self.assertEqual([(u'dir', None, 'directory'), (u'file', None, 'file'),
334
(u'link', None, 'symlink')], d.unversioned)
302
337
class TestIterChanges(TestCaseWithTwoTrees):
303
338
"""Test the comparison iterator"""
412
447
(entry.name, None), (entry.kind, None),
413
448
(entry.executable, None))
450
def renamed(self, from_tree, to_tree, file_id, content_changed):
451
from_entry = from_tree.inventory[file_id]
452
to_entry = to_tree.inventory[file_id]
453
from_path = from_tree.id2path(file_id)
454
to_path = to_tree.id2path(file_id)
455
return (file_id, to_path, content_changed, (True, True),
456
(from_entry.parent_id, to_entry.parent_id),
457
(from_entry.name, to_entry.name),
458
(from_entry.kind, to_entry.kind),
459
(from_entry.executable, to_entry.executable))
415
461
def unchanged(self, tree, file_id):
416
462
entry = tree.inventory[file_id]
417
463
parent = entry.parent_id
654
700
(False, False))],
655
701
list(tree2._iter_changes(tree1)))
657
def _todo_test_unversioned_paths_in_tree(self):
703
def test_default_ignores_unversioned_files(self):
658
704
tree1 = self.make_branch_and_tree('tree1')
659
705
tree2 = self.make_to_branch_and_tree('tree2')
660
self.build_tree(['tree2/file', 'tree2/dir/'])
662
os.symlink('target', 'tree2/link')
663
links_supported = True
665
# links_supported = False
706
self.build_tree(['tree1/a', 'tree1/c',
707
'tree2/a', 'tree2/b', 'tree2/c'])
708
tree1.add(['a', 'c'], ['a-id', 'c-id'])
709
tree2.add(['a', 'c'], ['a-id', 'c-id'])
666
711
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
667
root_id = tree1.path2id('')
668
712
tree1.lock_read()
669
713
self.addCleanup(tree1.unlock)
670
714
tree2.lock_read()
671
715
self.addCleanup(tree2.unlock)
673
self.unversioned(tree2, 'file'),
674
self.unversioned(tree2, 'dir'),
677
expected.append(self.unversioned(tree2, 'link'))
678
expected = sorted(expected)
717
# We should ignore the fact that 'b' exists in tree-2
718
# because the want_unversioned parameter was not given.
720
self.content_changed(tree2, 'a-id'),
721
self.content_changed(tree2, 'c-id'),
679
723
self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
681
def _todo_test_unversioned_paths_in_tree_specific_files(self):
682
tree1 = self.make_branch_and_tree('tree1')
683
tree2 = self.make_to_branch_and_tree('tree2')
684
self.build_tree(['tree2/file', 'tree2/dir/'])
686
os.symlink('target', 'tree2/link')
687
links_supported = True
689
# links_supported = False
725
def test_unversioned_paths_in_tree(self):
726
tree1 = self.make_branch_and_tree('tree1')
727
tree2 = self.make_to_branch_and_tree('tree2')
728
self.build_tree(['tree2/file', 'tree2/dir/'])
730
os.symlink('target', 'tree2/link')
731
links_supported = True
733
# links_supported = False
734
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
736
self.addCleanup(tree1.unlock)
738
self.addCleanup(tree2.unlock)
740
self.unversioned(tree2, 'file'),
741
self.unversioned(tree2, 'dir'),
744
expected.append(self.unversioned(tree2, 'link'))
745
expected = sorted(expected)
746
self.assertEqual(expected, self.do_iter_changes(tree1, tree2,
747
want_unversioned=True))
749
def test_unversioned_paths_in_tree_specific_files(self):
750
tree1 = self.make_branch_and_tree('tree1')
751
tree2 = self.make_to_branch_and_tree('tree2')
752
self.build_tree(['tree2/file', 'tree2/dir/'])
754
os.symlink('target', 'tree2/link')
755
links_supported = True
757
# links_supported = False
758
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
760
self.addCleanup(tree1.unlock)
762
self.addCleanup(tree2.unlock)
764
self.unversioned(tree2, 'file'),
765
self.unversioned(tree2, 'dir'),
767
specific_files=['file', 'dir']
769
expected.append(self.unversioned(tree2, 'link'))
770
specific_files.append('link')
771
expected = sorted(expected)
772
self.assertEqual(expected, self.do_iter_changes(tree1, tree2,
773
specific_files=specific_files, require_versioned=False,
774
want_unversioned=True))
776
def test_unversioned_paths_in_target_matching_source_old_names(self):
777
# its likely that naive implementations of unversioned file support
778
# will fail if the path was versioned, but is not any more,
779
# due to a rename, not due to unversioning it.
780
# That is, if the old tree has a versioned file 'foo', and
781
# the new tree has the same file but versioned as 'bar', and also
782
# has an unknown file 'foo', we should get back output for
784
tree1 = self.make_branch_and_tree('tree1')
785
tree2 = self.make_to_branch_and_tree('tree2')
786
self.build_tree(['tree2/file', 'tree2/dir/',
787
'tree1/file', 'tree2/movedfile',
788
'tree1/dir/', 'tree2/moveddir/'])
790
os.symlink('target', 'tree1/link')
791
os.symlink('target', 'tree2/link')
792
os.symlink('target', 'tree2/movedlink')
793
links_supported = True
795
# links_supported = False
796
tree1.add(['file', 'dir', 'link'], ['file-id', 'dir-id', 'link-id'])
797
tree2.add(['movedfile', 'moveddir', 'movedlink'],
798
['file-id', 'dir-id', 'link-id'])
690
799
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
691
800
root_id = tree1.path2id('')
692
801
tree1.lock_read()
694
803
tree2.lock_read()
695
804
self.addCleanup(tree2.unlock)
806
self.renamed(tree1, tree2, 'dir-id', False),
807
self.renamed(tree1, tree2, 'file-id', True),
697
808
self.unversioned(tree2, 'file'),
698
809
self.unversioned(tree2, 'dir'),
700
811
specific_files=['file', 'dir']
701
812
if links_supported:
813
expected.append(self.renamed(tree1, tree2, 'link-id', False))
702
814
expected.append(self.unversioned(tree2, 'link'))
703
815
specific_files.append('link')
704
816
expected = sorted(expected)
705
self.assertEqual(expected, self.do_iter_changes(tree1, tree2,
706
specific_files=specific_files))
817
# run once with, and once without specific files, to catch
818
# potentially different code paths.
819
self.assertEqual(expected, self.do_iter_changes(tree1, tree2,
820
require_versioned=False,
821
want_unversioned=True))
822
self.assertEqual(expected, self.do_iter_changes(tree1, tree2,
823
specific_files=specific_files, require_versioned=False,
824
want_unversioned=True))
826
def test_unversioned_subtree_only_emits_root(self):
827
tree1 = self.make_branch_and_tree('tree1')
828
tree2 = self.make_to_branch_and_tree('tree2')
829
self.build_tree(['tree2/dir/', 'tree2/dir/file'])
830
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
832
self.unversioned(tree2, 'dir'),
834
self.assertEqual(expected, self.do_iter_changes(tree1, tree2,
835
want_unversioned=True))
708
837
def make_trees_with_symlinks(self):
709
838
tree1 = self.make_branch_and_tree('tree1')
814
945
if f_id.endswith('_f-id'))
815
946
self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
817
def test_trees_with_unknown(self):
818
tree1 = self.make_branch_and_tree('tree1')
819
tree2 = self.make_to_branch_and_tree('tree2')
820
tree2.set_root_id(tree1.get_root_id())
821
self.build_tree(['tree1/a', 'tree1/c',
822
'tree2/a', 'tree2/b', 'tree2/c'])
823
tree1.add(['a', 'c'], ['a-id', 'c-id'])
824
tree2.add(['a', 'c'], ['a-id', 'c-id'])
826
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
828
self.addCleanup(tree1.unlock)
830
self.addCleanup(tree2.unlock)
832
# We should ignore the fact that 'b' exists in tree-2
834
self.content_changed(tree2, 'a-id'),
835
self.content_changed(tree2, 'c-id'),
837
self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
839
948
def test_trees_with_missing_dir(self):
840
949
tree1 = self.make_branch_and_tree('tree1')
841
950
tree2 = self.make_to_branch_and_tree('tree2')