~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/intertree_implementations/test_compare.py

(John Arbash Meinel) Update dirstate._iter_changes to return unicode for all paths (bug #92608)

Show diffs side-by-side

added added

removed removed

Lines of Context:
358
358
            tree1.unlock()
359
359
            tree2.unlock()
360
360
 
 
361
    def mutable_trees_to_locked_test_trees(self, tree1, tree2):
 
362
        """Convert the working trees into test trees.
 
363
 
 
364
        Read lock them, and add the unlock to the cleanup.
 
365
        """
 
366
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
367
        tree1.lock_read()
 
368
        self.addCleanup(tree1.unlock)
 
369
        tree2.lock_read()
 
370
        self.addCleanup(tree2.unlock)
 
371
        return tree1, tree2
 
372
 
361
373
    def make_tree_with_special_names(self):
362
374
        """Create a tree with filenames chosen to exercise the walk order."""
363
375
        tree1 = self.make_branch_and_tree('tree1')
365
377
        tree2.set_root_id(tree1.get_root_id())
366
378
        paths, path_ids = self._create_special_names(tree2, 'tree2')
367
379
        tree2.commit('initial', rev_id='rev-1')
368
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
380
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
369
381
        return (tree1, tree2, paths, path_ids)
370
382
 
371
383
    def make_trees_with_special_names(self):
378
390
        tree2.set_root_id(tree1.get_root_id())
379
391
        paths, path_ids = self._create_special_names(tree1, 'tree1')
380
392
        paths, path_ids = self._create_special_names(tree2, 'tree2')
381
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
393
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
382
394
        return (tree1, tree2, paths, path_ids)
383
395
 
384
396
    def _create_special_names(self, tree, base_path):
489
501
        tree2 = self.make_to_branch_and_tree('2')
490
502
        tree1 = self.get_tree_no_parents_no_content(tree1)
491
503
        tree2 = self.get_tree_no_parents_abc_content(tree2)
492
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
493
 
        tree1.lock_read()
494
 
        tree2.lock_read()
 
504
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
495
505
        expected_results = sorted([
496
506
            self.added(tree2, 'root-id'),
497
507
            self.added(tree2, 'a-id'),
498
508
            self.added(tree2, 'b-id'),
499
509
            self.added(tree2, 'c-id'),
500
510
            self.deleted(tree1, 'empty-root-id')])
501
 
        tree1.unlock()
502
 
        tree2.unlock()
503
511
        self.assertEqual(expected_results, self.do_iter_changes(tree1, tree2))
504
512
 
505
513
    def test_empty_to_abc_content_a_only(self):
507
515
        tree2 = self.make_to_branch_and_tree('2')
508
516
        tree1 = self.get_tree_no_parents_no_content(tree1)
509
517
        tree2 = self.get_tree_no_parents_abc_content(tree2)
510
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
511
 
        tree1.lock_read()
512
 
        tree2.lock_read()
 
518
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
513
519
        self.assertEqual(
514
520
            [self.added(tree2, 'a-id')],
515
521
            self.do_iter_changes(tree1, tree2, specific_files=['a']))
516
 
        tree1.unlock()
517
 
        tree2.unlock()
518
522
 
519
523
    def test_abc_content_to_empty_to_abc_content_a_only(self):
520
524
        tree1 = self.make_branch_and_tree('1')
521
525
        tree2 = self.make_to_branch_and_tree('2')
522
526
        tree1 = self.get_tree_no_parents_abc_content(tree1)
523
527
        tree2 = self.get_tree_no_parents_no_content(tree2)
524
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
525
 
        tree1.lock_read()
526
 
        tree2.lock_read()
 
528
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
527
529
        self.assertEqual(
528
530
            [self.deleted(tree1, 'a-id')],
529
531
            self.do_iter_changes(tree1, tree2, specific_files=['a']))
530
 
        tree1.unlock()
531
 
        tree2.unlock()
532
532
 
533
533
    def test_empty_to_abc_content_a_and_c_only(self):
534
534
        tree1 = self.make_branch_and_tree('1')
535
535
        tree2 = self.make_to_branch_and_tree('2')
536
536
        tree1 = self.get_tree_no_parents_no_content(tree1)
537
537
        tree2 = self.get_tree_no_parents_abc_content(tree2)
538
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
539
 
        tree1.lock_read()
540
 
        tree2.lock_read()
 
538
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
541
539
        expected_result = [self.added(tree2, 'a-id'), self.added(tree2, 'c-id')]
542
 
        tree1.unlock()
543
 
        tree2.unlock()
544
540
        self.assertEqual(expected_result,
545
541
            self.do_iter_changes(tree1, tree2, specific_files=['a', 'b/c']))
546
542
 
549
545
        tree2 = self.make_to_branch_and_tree('2')
550
546
        tree1 = self.get_tree_no_parents_abc_content(tree1)
551
547
        tree2 = self.get_tree_no_parents_no_content(tree2)
552
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
553
 
        tree1.lock_read()
554
 
        tree2.lock_read()
 
548
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
555
549
        def deleted(file_id):
556
550
            entry = tree1.inventory[file_id]
557
551
            path = tree1.id2path(file_id)
563
557
            self.added(tree2, 'empty-root-id'),
564
558
            deleted('root-id'), deleted('a-id'),
565
559
            deleted('b-id'), deleted('c-id')])
566
 
        tree1.unlock()
567
 
        tree2.unlock()
568
560
        self.assertEqual(
569
561
            expected_results,
570
562
            self.do_iter_changes(tree1, tree2))
669
661
        self.build_tree(['tree2/directory/'])
670
662
        tree2.add(['directory'], ['file-id'])
671
663
        os.rmdir('tree2/directory')
672
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
673
 
        tree1.lock_read()
674
 
        self.addCleanup(tree1.unlock)
675
 
        tree2.lock_read()
676
 
        self.addCleanup(tree2.unlock)
 
664
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
665
 
677
666
        root_id = tree1.path2id('')
678
667
        expected = sorted([
679
668
            self.missing('file-id', 'file', 'directory', root_id, 'file'),
686
675
        tree2 = self.make_to_branch_and_tree('2')
687
676
        tree1 = self.get_tree_no_parents_abc_content(tree1)
688
677
        tree2 = self.get_tree_no_parents_abc_content_5(tree2)
689
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
678
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
690
679
        root_id = tree1.path2id('')
691
 
        tree1.lock_read()
692
 
        self.addCleanup(tree1.unlock)
693
 
        tree2.lock_read()
694
 
        self.addCleanup(tree2.unlock)
 
680
 
695
681
        self.assertEqual(sorted([self.unchanged(tree1, root_id),
696
682
            self.unchanged(tree1, 'b-id'),
697
683
            ('a-id', ('a', 'd'), True, (True, True),
715
701
        subtree2 = self.make_to_branch_and_tree('2/sub')
716
702
        subtree2.set_root_id('subtree-id')
717
703
        tree2.add_reference(subtree2)
718
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
719
 
        tree1.lock_read()
720
 
        self.addCleanup(tree1.unlock)
721
 
        tree2.lock_read()
722
 
        self.addCleanup(tree2.unlock)
 
704
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
705
 
723
706
        self.assertEqual([], list(tree2._iter_changes(tree1)))
724
707
        subtree1.commit('commit', rev_id='commit-a')
725
708
        self.assertEqual([
759
742
        tree2.add(['sub'], ['subtree-id'])
760
743
        self.build_tree(['2/sub/file'])
761
744
        subtree2.add(['file'])
762
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
763
 
        tree1.lock_read()
764
 
        self.addCleanup(tree1.unlock)
765
 
        tree2.lock_read()
766
 
        self.addCleanup(tree2.unlock)
 
745
 
 
746
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
767
747
        # this should filter correctly from above
768
748
        self.assertEqual([self.added(tree2, 'subtree-id')],
769
749
            self.do_iter_changes(tree1, tree2, want_unversioned=True))
781
761
        tree1.add(['a', 'c'], ['a-id', 'c-id'])
782
762
        tree2.add(['a', 'c'], ['a-id', 'c-id'])
783
763
 
784
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
785
 
        tree1.lock_read()
786
 
        self.addCleanup(tree1.unlock)
787
 
        tree2.lock_read()
788
 
        self.addCleanup(tree2.unlock)
 
764
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
789
765
 
790
766
        # We should ignore the fact that 'b' exists in tree-2
791
767
        # because the want_unversioned parameter was not given.
805
781
        links_supported = True
806
782
        # except ???:
807
783
        #   links_supported = False
808
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
809
 
        tree1.lock_read()
810
 
        self.addCleanup(tree1.unlock)
811
 
        tree2.lock_read()
812
 
        self.addCleanup(tree2.unlock)
 
784
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
813
785
        expected = [
814
786
            self.unversioned(tree2, 'file'),
815
787
            self.unversioned(tree2, 'dir'),
829
801
        links_supported = True
830
802
        # except ???:
831
803
        #   links_supported = False
832
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
833
 
        tree1.lock_read()
834
 
        self.addCleanup(tree1.unlock)
835
 
        tree2.lock_read()
836
 
        self.addCleanup(tree2.unlock)
 
804
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
837
805
        expected = [
838
806
            self.unversioned(tree2, 'file'),
839
807
            self.unversioned(tree2, 'dir'),
871
839
        tree1.add(['file', 'dir', 'link'], ['file-id', 'dir-id', 'link-id'])
872
840
        tree2.add(['movedfile', 'moveddir', 'movedlink'],
873
841
            ['file-id', 'dir-id', 'link-id'])
874
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
842
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
875
843
        root_id = tree1.path2id('')
876
 
        tree1.lock_read()
877
 
        self.addCleanup(tree1.unlock)
878
 
        tree2.lock_read()
879
 
        self.addCleanup(tree2.unlock)
880
844
        expected = [
881
845
            self.renamed(tree1, tree2, 'dir-id', False),
882
846
            self.renamed(tree1, tree2, 'file-id', True),
952
916
        # except ???:
953
917
        #   raise TestSkipped('OS does not support symlinks')
954
918
        #   links_supported = False
955
 
        return self.mutable_trees_to_test_trees(tree1, tree2)
 
919
        return self.mutable_trees_to_locked_test_trees(tree1, tree2)
956
920
 
957
921
    def test_versioned_symlinks(self):
958
922
        if not has_symlinks():
959
923
            raise tests.TestSkipped("No symlink support")
960
924
        tree1, tree2 = self.make_trees_with_symlinks()
961
925
        root_id = tree1.path2id('')
962
 
        tree1.lock_read()
963
 
        self.addCleanup(tree1.unlock)
964
 
        tree2.lock_read()
965
 
        self.addCleanup(tree2.unlock)
966
926
        expected = [
967
927
            self.unchanged(tree1, tree1.path2id('')),
968
928
            self.added(tree2, 'added'),
985
945
            raise tests.TestSkipped("No symlink support")
986
946
        tree1, tree2 = self.make_trees_with_symlinks()
987
947
        root_id = tree1.path2id('')
988
 
        tree1.lock_read()
989
 
        self.addCleanup(tree1.unlock)
990
 
        tree2.lock_read()
991
 
        self.addCleanup(tree2.unlock)
992
948
        expected = [
993
949
            self.added(tree2, 'added'),
994
950
            self.content_changed(tree2, 'changed'),
1008
964
 
1009
965
    def test_tree_with_special_names(self):
1010
966
        tree1, tree2, paths, path_ids = self.make_tree_with_special_names()
1011
 
        tree1.lock_read()
1012
 
        self.addCleanup(tree1.unlock)
1013
 
        tree2.lock_read()
1014
 
        self.addCleanup(tree2.unlock)
1015
967
        expected = sorted(self.added(tree2, f_id) for f_id in path_ids)
1016
968
        self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
1017
969
 
1018
970
    def test_trees_with_special_names(self):
1019
971
        tree1, tree2, paths, path_ids = self.make_trees_with_special_names()
1020
 
        tree1.lock_read()
1021
 
        self.addCleanup(tree1.unlock)
1022
 
        tree2.lock_read()
1023
 
        self.addCleanup(tree2.unlock)
1024
972
        expected = sorted(self.content_changed(tree2, f_id) for f_id in path_ids
1025
973
                          if f_id.endswith('_f-id'))
1026
974
        self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
1036
984
                  ['a-id', 'b-id', 'c-id', 'd-id', 'e-id', 'f-id', 'g-id'])
1037
985
        tree2.add(['a', 'f', 'f/g'], ['a-id', 'f-id', 'g-id'])
1038
986
 
1039
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
1040
 
        tree1.lock_read()
1041
 
        self.addCleanup(tree1.unlock)
1042
 
        tree2.lock_read()
1043
 
        self.addCleanup(tree2.unlock)
 
987
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
1044
988
        # We should notice that 'b' and all its children are deleted
1045
989
        expected = sorted([
1046
990
            self.content_changed(tree2, 'a-id'),
1051
995
            self.deleted(tree1, 'e-id'),
1052
996
            ])
1053
997
        self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
 
998
 
 
999
    def test_added_unicode(self):
 
1000
        tree1 = self.make_branch_and_tree('tree1')
 
1001
        tree2 = self.make_to_branch_and_tree('tree2')
 
1002
        root_id = tree1.get_root_id()
 
1003
        tree2.set_root_id(root_id)
 
1004
 
 
1005
        # u'\u03b1' == GREEK SMALL LETTER ALPHA
 
1006
        # u'\u03c9' == GREEK SMALL LETTER OMEGA
 
1007
        a_id = u'\u03b1-id'.encode('utf8')
 
1008
        added_id = u'\u03c9_added_id'.encode('utf8')
 
1009
        try:
 
1010
            self.build_tree([u'tree1/\u03b1/',
 
1011
                             u'tree2/\u03b1/',
 
1012
                             u'tree2/\u03b1/\u03c9-added',
 
1013
                            ])
 
1014
        except UnicodeError:
 
1015
            raise tests.TestSkipped("Could not create Unicode files.")
 
1016
        tree1.add([u'\u03b1'], [a_id])
 
1017
        tree2.add([u'\u03b1', u'\u03b1/\u03c9-added'], [a_id, added_id])
 
1018
 
 
1019
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
1020
 
 
1021
        self.assertEqual([self.added(tree2, added_id)],
 
1022
                         self.do_iter_changes(tree1, tree2))
 
1023
        self.assertEqual([self.added(tree2, added_id)],
 
1024
                         self.do_iter_changes(tree1, tree2,
 
1025
                                              specific_files=[u'\u03b1']))
 
1026
 
 
1027
    def test_deleted_unicode(self):
 
1028
        tree1 = self.make_branch_and_tree('tree1')
 
1029
        tree2 = self.make_to_branch_and_tree('tree2')
 
1030
        root_id = tree1.get_root_id()
 
1031
        tree2.set_root_id(root_id)
 
1032
 
 
1033
        # u'\u03b1' == GREEK SMALL LETTER ALPHA
 
1034
        # u'\u03c9' == GREEK SMALL LETTER OMEGA
 
1035
        a_id = u'\u03b1-id'.encode('utf8')
 
1036
        deleted_id = u'\u03c9_deleted_id'.encode('utf8')
 
1037
        try:
 
1038
            self.build_tree([u'tree1/\u03b1/',
 
1039
                             u'tree1/\u03b1/\u03c9-deleted',
 
1040
                             u'tree2/\u03b1/',
 
1041
                            ])
 
1042
        except UnicodeError:
 
1043
            raise tests.TestSkipped("Could not create Unicode files.")
 
1044
        tree1.add([u'\u03b1', u'\u03b1/\u03c9-deleted'], [a_id, deleted_id])
 
1045
        tree2.add([u'\u03b1'], [a_id])
 
1046
 
 
1047
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
1048
 
 
1049
        self.assertEqual([self.deleted(tree1, deleted_id)],
 
1050
                         self.do_iter_changes(tree1, tree2))
 
1051
        self.assertEqual([self.deleted(tree1, deleted_id)],
 
1052
                         self.do_iter_changes(tree1, tree2,
 
1053
                                              specific_files=[u'\u03b1']))
 
1054
 
 
1055
    def test_modified_unicode(self):
 
1056
        tree1 = self.make_branch_and_tree('tree1')
 
1057
        tree2 = self.make_to_branch_and_tree('tree2')
 
1058
        root_id = tree1.get_root_id()
 
1059
        tree2.set_root_id(root_id)
 
1060
 
 
1061
        # u'\u03b1' == GREEK SMALL LETTER ALPHA
 
1062
        # u'\u03c9' == GREEK SMALL LETTER OMEGA
 
1063
        a_id = u'\u03b1-id'.encode('utf8')
 
1064
        mod_id = u'\u03c9_mod_id'.encode('utf8')
 
1065
        try:
 
1066
            self.build_tree([u'tree1/\u03b1/',
 
1067
                             u'tree1/\u03b1/\u03c9-modified',
 
1068
                             u'tree2/\u03b1/',
 
1069
                             u'tree2/\u03b1/\u03c9-modified',
 
1070
                            ])
 
1071
        except UnicodeError:
 
1072
            raise tests.TestSkipped("Could not create Unicode files.")
 
1073
        tree1.add([u'\u03b1', u'\u03b1/\u03c9-modified'], [a_id, mod_id])
 
1074
        tree2.add([u'\u03b1', u'\u03b1/\u03c9-modified'], [a_id, mod_id])
 
1075
 
 
1076
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
1077
 
 
1078
        self.assertEqual([self.content_changed(tree1, mod_id)],
 
1079
                         self.do_iter_changes(tree1, tree2))
 
1080
        self.assertEqual([self.content_changed(tree1, mod_id)],
 
1081
                         self.do_iter_changes(tree1, tree2,
 
1082
                                              specific_files=[u'\u03b1']))
 
1083
 
 
1084
    def test_renamed_unicode(self):
 
1085
        tree1 = self.make_branch_and_tree('tree1')
 
1086
        tree2 = self.make_to_branch_and_tree('tree2')
 
1087
        root_id = tree1.get_root_id()
 
1088
        tree2.set_root_id(root_id)
 
1089
 
 
1090
        # u'\u03b1' == GREEK SMALL LETTER ALPHA
 
1091
        # u'\u03c9' == GREEK SMALL LETTER OMEGA
 
1092
        a_id = u'\u03b1-id'.encode('utf8')
 
1093
        rename_id = u'\u03c9_rename_id'.encode('utf8')
 
1094
        try:
 
1095
            self.build_tree([u'tree1/\u03b1/',
 
1096
                             u'tree2/\u03b1/',
 
1097
                            ])
 
1098
        except UnicodeError:
 
1099
            raise tests.TestSkipped("Could not create Unicode files.")
 
1100
        self.build_tree_contents([(u'tree1/\u03c9-source', 'contents\n'),
 
1101
                                  (u'tree2/\u03b1/\u03c9-target', 'contents\n'),
 
1102
                                 ])
 
1103
        tree1.add([u'\u03b1', u'\u03c9-source'], [a_id, rename_id])
 
1104
        tree2.add([u'\u03b1', u'\u03b1/\u03c9-target'], [a_id, rename_id])
 
1105
 
 
1106
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
1107
 
 
1108
        self.assertEqual([self.renamed(tree1, tree2, rename_id, False)],
 
1109
                         self.do_iter_changes(tree1, tree2))
 
1110
        self.assertEqual([self.renamed(tree1, tree2, rename_id, False)],
 
1111
                         self.do_iter_changes(tree1, tree2,
 
1112
                                              specific_files=[u'\u03b1']))
 
1113
 
 
1114
    def test_unchanged_unicode(self):
 
1115
        tree1 = self.make_branch_and_tree('tree1')
 
1116
        tree2 = self.make_to_branch_and_tree('tree2')
 
1117
        root_id = tree1.get_root_id()
 
1118
        tree2.set_root_id(root_id)
 
1119
        # u'\u03b1' == GREEK SMALL LETTER ALPHA
 
1120
        # u'\u03c9' == GREEK SMALL LETTER OMEGA
 
1121
        a_id = u'\u03b1-id'.encode('utf8')
 
1122
        subfile_id = u'\u03c9-subfile-id'.encode('utf8')
 
1123
        rootfile_id = u'\u03c9-root-id'.encode('utf8')
 
1124
        try:
 
1125
            self.build_tree([u'tree1/\u03b1/',
 
1126
                             u'tree2/\u03b1/',
 
1127
                            ])
 
1128
        except UnicodeError:
 
1129
            raise tests.TestSkipped("Could not create Unicode files.")
 
1130
        self.build_tree_contents([
 
1131
            (u'tree1/\u03b1/\u03c9-subfile', 'sub contents\n'),
 
1132
            (u'tree2/\u03b1/\u03c9-subfile', 'sub contents\n'),
 
1133
            (u'tree1/\u03c9-rootfile', 'root contents\n'),
 
1134
            (u'tree2/\u03c9-rootfile', 'root contents\n'),
 
1135
            ])
 
1136
        tree1.add([u'\u03b1', u'\u03b1/\u03c9-subfile', u'\u03c9-rootfile'],
 
1137
                  [a_id, subfile_id, rootfile_id])
 
1138
        tree2.add([u'\u03b1', u'\u03b1/\u03c9-subfile', u'\u03c9-rootfile'],
 
1139
                  [a_id, subfile_id, rootfile_id])
 
1140
 
 
1141
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
1142
 
 
1143
        expected = sorted([
 
1144
            self.unchanged(tree1, root_id),
 
1145
            self.unchanged(tree1, a_id),
 
1146
            self.unchanged(tree1, subfile_id),
 
1147
            self.unchanged(tree1, rootfile_id),
 
1148
            ])
 
1149
        self.assertEqual(expected,
 
1150
                         self.do_iter_changes(tree1, tree2,
 
1151
                                              include_unchanged=True))
 
1152
 
 
1153
        # We should also be able to select just a subset
 
1154
        expected = sorted([
 
1155
            self.unchanged(tree1, a_id),
 
1156
            self.unchanged(tree1, subfile_id),
 
1157
            ])
 
1158
        self.assertEqual(expected,
 
1159
                         self.do_iter_changes(tree1, tree2,
 
1160
                                              specific_files=[u'\u03b1'],
 
1161
                                              include_unchanged=True))
 
1162
 
 
1163
    def test_unknown_unicode(self):
 
1164
        tree1 = self.make_branch_and_tree('tree1')
 
1165
        tree2 = self.make_to_branch_and_tree('tree2')
 
1166
        root_id = tree1.get_root_id()
 
1167
        tree2.set_root_id(root_id)
 
1168
        # u'\u03b1' == GREEK SMALL LETTER ALPHA
 
1169
        # u'\u03c9' == GREEK SMALL LETTER OMEGA
 
1170
        a_id = u'\u03b1-id'.encode('utf8')
 
1171
        try:
 
1172
            self.build_tree([u'tree1/\u03b1/',
 
1173
                             u'tree2/\u03b1/',
 
1174
                             u'tree2/\u03b1/unknown_dir/',
 
1175
                             u'tree2/\u03b1/unknown_file',
 
1176
                             u'tree2/\u03b1/unknown_dir/file',
 
1177
                             u'tree2/\u03c9-unknown_root_file',
 
1178
                            ])
 
1179
        except UnicodeError:
 
1180
            raise tests.TestSkipped("Could not create Unicode files.")
 
1181
        tree1.add([u'\u03b1'], [a_id])
 
1182
        tree2.add([u'\u03b1'], [a_id])
 
1183
 
 
1184
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
1185
 
 
1186
        expected = sorted([
 
1187
            self.unversioned(tree2, u'\u03b1/unknown_dir'),
 
1188
            self.unversioned(tree2, u'\u03b1/unknown_file'),
 
1189
            self.unversioned(tree2, u'\u03c9-unknown_root_file'),
 
1190
            # a/unknown_dir/file should not be included because we should not
 
1191
            # recurse into unknown_dir
 
1192
            # self.unversioned(tree2, 'a/unknown_dir/file'),
 
1193
            ])
 
1194
        self.assertEqual(expected,
 
1195
                         self.do_iter_changes(tree1, tree2,
 
1196
                                              require_versioned=False,
 
1197
                                              want_unversioned=True))
 
1198
        self.assertEqual([], # Without want_unversioned we should get nothing
 
1199
                         self.do_iter_changes(tree1, tree2))
 
1200
 
 
1201
        # We should also be able to select just a subset
 
1202
        expected = sorted([
 
1203
            self.unversioned(tree2, u'\u03b1/unknown_dir'),
 
1204
            self.unversioned(tree2, u'\u03b1/unknown_file'),
 
1205
            ])
 
1206
        self.assertEqual(expected,
 
1207
                         self.do_iter_changes(tree1, tree2,
 
1208
                                              specific_files=[u'\u03b1'],
 
1209
                                              require_versioned=False,
 
1210
                                              want_unversioned=True))
 
1211
        self.assertEqual([], # Without want_unversioned we should get nothing
 
1212
                         self.do_iter_changes(tree1, tree2,
 
1213
                                              specific_files=[u'\u03b1']))