~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2008-07-31 04:51:46 UTC
  • mto: (3363.16.1 __contains__)
  • mto: This revision was merged to the branch mainline in revision 3726.
  • Revision ID: aaron@aaronbentley.com-20080731045146-fhfu8aywmwvusmp7
Ensure TransformPreview is finalized

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
        tree2.set_root_id(tree1.get_root_id())
50
50
        tree1 = self.get_tree_no_parents_no_content(tree1)
51
51
        tree2 = self.get_tree_no_parents_no_content(tree2)
52
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
52
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
53
53
        d = self.intertree_class(tree1, tree2).compare()
54
54
        self.assertEqual([], d.added)
55
55
        self.assertEqual([], d.modified)
63
63
        tree2.set_root_id(tree1.get_root_id())
64
64
        tree1 = self.get_tree_no_parents_no_content(tree1)
65
65
        tree2 = self.get_tree_no_parents_abc_content(tree2)
66
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
66
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
67
67
        d = self.intertree_class(tree1, tree2).compare()
68
68
        self.assertEqual([('a', 'a-id', 'file'),
69
69
                          ('b', 'b-id', 'directory'),
93
93
        # default intertree, but may perform a commit for other tree types,
94
94
        # which may reduce the validity of the test. XXX: Think about how to
95
95
        # address this.
96
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
96
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
97
97
        d = self.intertree_class(tree1, tree2).compare()
98
98
        self.assertEqual([], d.added)
99
99
        self.assertEqual([], d.modified)
107
107
        tree2.set_root_id(tree1.get_root_id())
108
108
        tree1 = self.get_tree_no_parents_abc_content(tree1)
109
109
        tree2 = self.get_tree_no_parents_no_content(tree2)
110
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
110
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
111
111
        d = self.intertree_class(tree1, tree2).compare()
112
112
        self.assertEqual([], d.added)
113
113
        self.assertEqual([], d.modified)
124
124
        tree2.set_root_id(tree1.get_root_id())
125
125
        tree1 = self.get_tree_no_parents_abc_content(tree1)
126
126
        tree2 = self.get_tree_no_parents_abc_content_2(tree2)
127
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
127
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
128
128
        d = self.intertree_class(tree1, tree2).compare()
129
129
        self.assertEqual([], d.added)
130
130
        self.assertEqual([('a', 'a-id', 'file', True, False)], d.modified)
138
138
        tree2.set_root_id(tree1.get_root_id())
139
139
        tree1 = self.get_tree_no_parents_abc_content(tree1)
140
140
        tree2 = self.get_tree_no_parents_abc_content_3(tree2)
141
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
141
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
142
142
        d = self.intertree_class(tree1, tree2).compare()
143
143
        self.assertEqual([], d.added)
144
144
        self.assertEqual([('b/c', 'c-id', 'file', False, True)], d.modified)
152
152
        tree2.set_root_id(tree1.get_root_id())
153
153
        tree1 = self.get_tree_no_parents_abc_content(tree1)
154
154
        tree2 = self.get_tree_no_parents_abc_content_4(tree2)
155
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
155
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
156
156
        d = self.intertree_class(tree1, tree2).compare()
157
157
        self.assertEqual([], d.added)
158
158
        self.assertEqual([], d.modified)
166
166
        tree2.set_root_id(tree1.get_root_id())
167
167
        tree1 = self.get_tree_no_parents_abc_content(tree1)
168
168
        tree2 = self.get_tree_no_parents_abc_content_5(tree2)
169
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
169
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
170
170
        d = self.intertree_class(tree1, tree2).compare()
171
171
        self.assertEqual([], d.added)
172
172
        self.assertEqual([], d.modified)
180
180
        tree2.set_root_id(tree1.get_root_id())
181
181
        tree1 = self.get_tree_no_parents_abc_content(tree1)
182
182
        tree2 = self.get_tree_no_parents_abc_content_6(tree2)
183
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
183
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
184
184
        d = self.intertree_class(tree1, tree2).compare()
185
185
        self.assertEqual([], d.added)
186
186
        self.assertEqual([], d.modified)
194
194
        tree2.set_root_id(tree1.get_root_id())
195
195
        tree1 = self.get_tree_no_parents_no_content(tree1)
196
196
        tree2 = self.get_tree_no_parents_abc_content(tree2)
197
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
197
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
198
198
        d = self.intertree_class(tree1, tree2).compare(specific_files=['a'])
199
199
        self.assertEqual([('a', 'a-id', 'file')], d.added)
200
200
        self.assertEqual([], d.modified)
207
207
        tree2 = self.make_to_branch_and_tree('2')
208
208
        tree1 = self.get_tree_no_parents_no_content(tree1)
209
209
        tree2 = self.get_tree_no_parents_abc_content(tree2)
210
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
210
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
211
211
        d = self.intertree_class(tree1, tree2).compare(
212
212
            specific_files=['a', 'b/c'])
213
213
        self.assertEqual(
224
224
        tree2 = self.make_to_branch_and_tree('2')
225
225
        tree1 = self.get_tree_no_parents_no_content(tree1)
226
226
        tree2 = self.get_tree_no_parents_abc_content(tree2)
227
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
227
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
228
228
        d = self.intertree_class(tree1, tree2).compare(specific_files=['b'])
229
229
        self.assertEqual(
230
230
            [('b', 'b-id', 'directory'),('b/c', 'c-id', 'file')],
240
240
        tree2 = self.make_to_branch_and_tree('2')
241
241
        tree1 = self.get_tree_no_parents_abc_content(tree1)
242
242
        tree2 = self.get_tree_no_parents_abc_content_5(tree2)
243
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
243
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
244
244
        d = self.intertree_class(tree1, tree2).compare(want_unchanged=True)
245
245
        self.assertEqual([], d.added)
246
246
        self.assertEqual([], d.modified)
256
256
        tree2 = self.make_to_branch_and_tree('2')
257
257
        tree1 = self.get_tree_no_parents_abc_content(tree1)
258
258
        tree2 = self.get_tree_no_parents_abc_content_3(tree2)
259
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
259
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
260
260
        d = self.intertree_class(tree1, tree2).compare(specific_files=['b'])
261
261
        # the type of tree-3 does not matter - it is used as a lookup, not
262
262
        # a dispatch. XXX: For dirstate it does speak to the optimisability of
291
291
        tree2 = self.make_to_branch_and_tree('2')
292
292
        tree1 = self.get_tree_no_parents_no_content(tree1)
293
293
        tree2 = self.get_tree_no_parents_abc_content(tree2)
294
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
294
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
295
295
        self.assertRaises(errors.PathsNotVersionedError, 
296
296
            self.intertree_class(tree1, tree2).compare,
297
297
            specific_files=['d'],
306
306
        tree1.add(['a', 'c'], ['a-id', 'c-id'])
307
307
        tree2.add(['a', 'c'], ['a-id', 'c-id'])
308
308
 
309
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
309
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
310
310
        d = self.intertree_class(tree1, tree2).compare()
311
311
        self.assertEqual([], d.added)
312
312
        self.assertEqual([(u'a', 'a-id', 'file', True, False),
326
326
            links_supported = True
327
327
        else:
328
328
            links_supported = False
329
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
329
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
330
330
        d = self.intertree_class(tree1, tree2).compare(want_unversioned=True)
331
331
        self.assertEqual([], d.added)
332
332
        self.assertEqual([], d.modified)
366
366
 
367
367
        Read lock them, and add the unlock to the cleanup.
368
368
        """
369
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
369
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
370
370
        tree1.lock_read()
371
371
        self.addCleanup(tree1.unlock)
372
372
        tree2.lock_read()
428
428
        tree2 = self.make_to_branch_and_tree('2')
429
429
        tree1 = self.get_tree_no_parents_no_content(tree1)
430
430
        tree2 = self.get_tree_no_parents_no_content(tree2)
431
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
431
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
432
432
        self.assertEqual([], self.do_iter_changes(tree1, tree2))
433
433
 
434
434
    def added(self, tree, file_id):
593
593
        tree2 = self.make_to_branch_and_tree('2')
594
594
        tree1 = self.get_tree_no_parents_abc_content(tree1)
595
595
        tree2 = self.get_tree_no_parents_abc_content_2(tree2)
596
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
596
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
597
597
        root_id = tree1.path2id('')
598
598
        self.assertEqual([('a-id', ('a', 'a'), True, (True, True),
599
599
                           (root_id, root_id), ('a', 'a'),
605
605
        tree2 = self.make_to_branch_and_tree('2')
606
606
        tree1 = self.get_tree_no_parents_abc_content(tree1)
607
607
        tree2 = self.get_tree_no_parents_abc_content_3(tree2)
608
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
608
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
609
609
        self.assertEqual([('c-id', ('b/c', 'b/c'), False, (True, True),
610
610
                           ('b-id', 'b-id'), ('c', 'c'), ('file', 'file'),
611
611
                          (False, True))],
621
621
        self.build_tree(['1/a-empty/', '2/a-empty/'])
622
622
        tree1.add(['a-empty'], ['a-empty'])
623
623
        tree2.add(['a-empty'], ['a-empty'])
624
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
624
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
625
625
        expected = []
626
626
        self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
627
627
 
630
630
        tree2 = self.make_to_branch_and_tree('2')
631
631
        tree1 = self.get_tree_no_parents_abc_content(tree1)
632
632
        tree2 = self.get_tree_no_parents_abc_content_4(tree2)
633
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
633
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
634
634
        root_id = tree1.path2id('')
635
635
        self.assertEqual([('a-id', ('a', 'd'), False, (True, True),
636
636
                           (root_id, root_id), ('a', 'd'), ('file', 'file'),
642
642
        tree2 = self.make_to_branch_and_tree('2')
643
643
        tree1 = self.get_tree_no_parents_abc_content(tree1)
644
644
        tree2 = self.get_tree_no_parents_abc_content_5(tree2)
645
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
645
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
646
646
        root_id = tree1.path2id('')
647
647
        self.assertEqual([('a-id', ('a', 'd'), True, (True, True),
648
648
                           (root_id, root_id), ('a', 'd'), ('file', 'file'),
654
654
        tree2 = self.make_to_branch_and_tree('2')
655
655
        tree1 = self.get_tree_no_parents_abc_content(tree1)
656
656
        tree2 = self.get_tree_no_parents_abc_content_6(tree2)
657
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
657
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
658
658
        root_id = tree1.path2id('')
659
659
        self.assertEqual([('c-id', ('b/c', 'e'), False, (True, True),
660
660
                           ('b-id', root_id), ('c', 'e'), ('file', 'file'),
670
670
        os.unlink('2/a')
671
671
        shutil.rmtree('2/b')
672
672
        # TODO ? have a symlink here?
673
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
673
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
674
674
        root_id = tree1.path2id('')
675
675
        expected = sorted([
676
676
            self.missing('a-id', 'a', 'a', root_id, 'file'),
941
941
        tree2 = self.make_to_branch_and_tree('tree2')
942
942
        tree2.set_root_id(tree1.get_root_id())
943
943
        self.build_tree(['tree2/dir/', 'tree2/dir/file'])
944
 
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
944
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
945
945
        expected = [
946
946
            self.unversioned(tree2, 'dir'),
947
947
            ]