~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
        tree1 = self.make_branch_and_tree('1')
29
29
        tree2 = self.make_to_branch_and_tree('2')
30
30
        tree1 = self.get_tree_no_parents_no_content(tree1)
31
 
        tree2 = self.get_to_tree_no_parents_no_content(tree2)
 
31
        tree2 = self.get_tree_no_parents_no_content(tree2)
 
32
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
32
33
        d = self.intertree_class(tree1, tree2).compare()
33
34
        self.assertEqual([], d.added)
34
35
        self.assertEqual([], d.modified)
40
41
        tree1 = self.make_branch_and_tree('1')
41
42
        tree2 = self.make_to_branch_and_tree('2')
42
43
        tree1 = self.get_tree_no_parents_no_content(tree1)
43
 
        tree2 = self.get_to_tree_no_parents_abc_content(tree2)
 
44
        tree2 = self.get_tree_no_parents_abc_content(tree2)
 
45
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
44
46
        d = self.intertree_class(tree1, tree2).compare()
45
47
        self.assertEqual([('a', 'a-id', 'file'),
46
48
                          ('b', 'b-id', 'directory'),
52
54
        self.assertEqual([], d.unchanged)
53
55
 
54
56
    def test_dangling(self):
 
57
        # This test depends on the ability for some trees to have a difference
 
58
        # between a 'versioned present' and 'versioned not present' (aka
 
59
        # dangling) file. In this test there are two trees each with a separate
 
60
        # dangling file, and the dangling files should be considered absent for
 
61
        # the test.
55
62
        tree1 = self.make_branch_and_tree('1')
56
 
        tree2 = self.make_branch_and_tree('2')
 
63
        tree2 = self.make_to_branch_and_tree('2')
57
64
        self.build_tree(['2/a'])
58
65
        tree2.add('a')
59
66
        os.unlink('2/a')
60
67
        self.build_tree(['1/b'])
61
68
        tree1.add('b')
62
69
        os.unlink('1/b')
 
70
        # the conversion to test trees here will leave the trees intact for the
 
71
        # default intertree, but may perform a commit for other tree types,
 
72
        # which may reduce the validity of the test. XXX: Think about how to
 
73
        # address this.
 
74
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
63
75
        d = self.intertree_class(tree1, tree2).compare()
64
76
        self.assertEqual([], d.added)
65
77
        self.assertEqual([], d.modified)
71
83
        tree1 = self.make_branch_and_tree('1')
72
84
        tree2 = self.make_to_branch_and_tree('2')
73
85
        tree1 = self.get_tree_no_parents_abc_content(tree1)
74
 
        tree2 = self.get_to_tree_no_parents_no_content(tree2)
 
86
        tree2 = self.get_tree_no_parents_no_content(tree2)
 
87
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
75
88
        d = self.intertree_class(tree1, tree2).compare()
76
89
        self.assertEqual([], d.added)
77
90
        self.assertEqual([], d.modified)
86
99
        tree1 = self.make_branch_and_tree('1')
87
100
        tree2 = self.make_to_branch_and_tree('2')
88
101
        tree1 = self.get_tree_no_parents_abc_content(tree1)
89
 
        tree2 = self.get_to_tree_no_parents_abc_content_2(tree2)
 
102
        tree2 = self.get_tree_no_parents_abc_content_2(tree2)
 
103
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
90
104
        d = self.intertree_class(tree1, tree2).compare()
91
105
        self.assertEqual([], d.added)
92
106
        self.assertEqual([('a', 'a-id', 'file', True, False)], d.modified)
98
112
        tree1 = self.make_branch_and_tree('1')
99
113
        tree2 = self.make_to_branch_and_tree('2')
100
114
        tree1 = self.get_tree_no_parents_abc_content(tree1)
101
 
        tree2 = self.get_to_tree_no_parents_abc_content_3(tree2)
 
115
        tree2 = self.get_tree_no_parents_abc_content_3(tree2)
 
116
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
102
117
        d = self.intertree_class(tree1, tree2).compare()
103
118
        self.assertEqual([], d.added)
104
119
        self.assertEqual([('b/c', 'c-id', 'file', False, True)], d.modified)
110
125
        tree1 = self.make_branch_and_tree('1')
111
126
        tree2 = self.make_to_branch_and_tree('2')
112
127
        tree1 = self.get_tree_no_parents_abc_content(tree1)
113
 
        tree2 = self.get_to_tree_no_parents_abc_content_4(tree2)
 
128
        tree2 = self.get_tree_no_parents_abc_content_4(tree2)
 
129
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
114
130
        d = self.intertree_class(tree1, tree2).compare()
115
131
        self.assertEqual([], d.added)
116
132
        self.assertEqual([], d.modified)
122
138
        tree1 = self.make_branch_and_tree('1')
123
139
        tree2 = self.make_to_branch_and_tree('2')
124
140
        tree1 = self.get_tree_no_parents_abc_content(tree1)
125
 
        tree2 = self.get_to_tree_no_parents_abc_content_5(tree2)
 
141
        tree2 = self.get_tree_no_parents_abc_content_5(tree2)
 
142
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
126
143
        d = self.intertree_class(tree1, tree2).compare()
127
144
        self.assertEqual([], d.added)
128
145
        self.assertEqual([], d.modified)
134
151
        tree1 = self.make_branch_and_tree('1')
135
152
        tree2 = self.make_to_branch_and_tree('2')
136
153
        tree1 = self.get_tree_no_parents_abc_content(tree1)
137
 
        tree2 = self.get_to_tree_no_parents_abc_content_6(tree2)
 
154
        tree2 = self.get_tree_no_parents_abc_content_6(tree2)
 
155
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
138
156
        d = self.intertree_class(tree1, tree2).compare()
139
157
        self.assertEqual([], d.added)
140
158
        self.assertEqual([], d.modified)
146
164
        tree1 = self.make_branch_and_tree('1')
147
165
        tree2 = self.make_to_branch_and_tree('2')
148
166
        tree1 = self.get_tree_no_parents_no_content(tree1)
149
 
        tree2 = self.get_to_tree_no_parents_abc_content(tree2)
 
167
        tree2 = self.get_tree_no_parents_abc_content(tree2)
 
168
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
150
169
        d = self.intertree_class(tree1, tree2).compare(specific_files=['a'])
151
170
        self.assertEqual([('a', 'a-id', 'file')], d.added)
152
171
        self.assertEqual([], d.modified)
158
177
        tree1 = self.make_branch_and_tree('1')
159
178
        tree2 = self.make_to_branch_and_tree('2')
160
179
        tree1 = self.get_tree_no_parents_no_content(tree1)
161
 
        tree2 = self.get_to_tree_no_parents_abc_content(tree2)
 
180
        tree2 = self.get_tree_no_parents_abc_content(tree2)
 
181
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
162
182
        d = self.intertree_class(tree1, tree2).compare(
163
183
            specific_files=['a', 'b/c'])
164
184
        self.assertEqual(
174
194
        tree1 = self.make_branch_and_tree('1')
175
195
        tree2 = self.make_to_branch_and_tree('2')
176
196
        tree1 = self.get_tree_no_parents_no_content(tree1)
177
 
        tree2 = self.get_to_tree_no_parents_abc_content(tree2)
 
197
        tree2 = self.get_tree_no_parents_abc_content(tree2)
 
198
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
178
199
        d = self.intertree_class(tree1, tree2).compare(specific_files=['b'])
179
200
        self.assertEqual(
180
201
            [('b', 'b-id', 'directory'),('b/c', 'c-id', 'file')],
189
210
        tree1 = self.make_branch_and_tree('1')
190
211
        tree2 = self.make_to_branch_and_tree('2')
191
212
        tree1 = self.get_tree_no_parents_abc_content(tree1)
192
 
        tree2 = self.get_to_tree_no_parents_abc_content_5(tree2)
 
213
        tree2 = self.get_tree_no_parents_abc_content_5(tree2)
 
214
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
193
215
        d = self.intertree_class(tree1, tree2).compare(want_unchanged=True)
194
216
        self.assertEqual([], d.added)
195
217
        self.assertEqual([], d.modified)
204
226
        tree1 = self.make_branch_and_tree('1')
205
227
        tree2 = self.make_to_branch_and_tree('2')
206
228
        tree1 = self.get_tree_no_parents_abc_content(tree1)
207
 
        tree2 = self.get_to_tree_no_parents_abc_content_3(tree2)
 
229
        tree2 = self.get_tree_no_parents_abc_content_3(tree2)
 
230
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
231
        d = self.intertree_class(tree1, tree2).compare(specific_files=['b'])
208
232
        # the type of tree-3 does not matter - it is used as a lookup, not
209
 
        # a dispatch
 
233
        # a dispatch. XXX: For dirstate it does speak to the optimisability of
 
234
        # the lookup, in merged trees it can be fast-pathed. We probably want
 
235
        # two tests: one as is, and one with it as a pending merge.
210
236
        tree3 = self.make_branch_and_tree('3')
211
237
        tree3 = self.get_tree_no_parents_abc_content_6(tree3)
 
238
        tree3.lock_read()
 
239
        self.addCleanup(tree3.unlock)
212
240
        # tree 3 has 'e' which is 'c-id'. Tree 1 has c-id at b/c, and Tree 2
213
241
        # has c-id at b/c with its exec flag toggled.
214
242
        # without extra_trees, we should get no modifications from this
233
261
        tree1 = self.make_branch_and_tree('1')
234
262
        tree2 = self.make_to_branch_and_tree('2')
235
263
        tree1 = self.get_tree_no_parents_no_content(tree1)
236
 
        tree2 = self.get_to_tree_no_parents_abc_content(tree2)
 
264
        tree2 = self.get_tree_no_parents_abc_content(tree2)
 
265
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
237
266
        self.assertRaises(errors.PathsNotVersionedError, 
238
267
            self.intertree_class(tree1, tree2).compare,
239
268
            specific_files=['d'],
243
272
class TestIterChanges(TestCaseWithTwoTrees):
244
273
    """Test the comparison iterator"""
245
274
 
 
275
    def do_iter_changes(self, tree1, tree2, **extra_args):
 
276
        """Helper to run _iter_changes from tree1 to tree2.
 
277
        
 
278
        :param tree1, tree2:  The source and target trees. These will be locked
 
279
            automatically.
 
280
        :param **extra_args: Extra args to pass to _iter_changes. This is not
 
281
            inspected by this test helper.
 
282
        """
 
283
        tree1.lock_read()
 
284
        tree2.lock_read()
 
285
        try:
 
286
            return list(self.intertree_class(tree1, tree2)
 
287
                ._iter_changes(**extra_args))
 
288
        finally:
 
289
            tree1.unlock()
 
290
            tree2.unlock()
 
291
 
246
292
    def test_compare_empty_trees(self):
247
293
        tree1 = self.make_branch_and_tree('1')
248
294
        tree2 = self.make_to_branch_and_tree('2')
249
295
        tree1 = self.get_tree_no_parents_no_content(tree1)
250
 
        tree2 = self.get_to_tree_no_parents_no_content(tree2)
251
 
        tree1.lock_read()
252
 
        self.addCleanup(tree1.unlock)
253
 
        tree2.lock_read()
254
 
        self.addCleanup(tree2.unlock)
255
 
        self.assertEqual([], list(tree2._iter_changes(tree1)))
 
296
        tree2 = self.get_tree_no_parents_no_content(tree2)
 
297
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
 
298
        self.assertEqual([], self.do_iter_changes(tree1, tree2))
256
299
 
257
300
    def added(self, tree, file_id):
258
301
        entry = tree.inventory[file_id]
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)
276
 
            
 
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)))
 
322
        expected_results = [
 
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')]
 
328
        tree1.unlock()
 
329
        tree2.unlock()
 
330
        self.assertEqual(expected_results, self.do_iter_changes(tree1, tree2))
287
331
 
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)
293
 
        tree1.lock_read()
294
 
        self.addCleanup(tree1.unlock)
295
 
        tree2.lock_read()
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)
 
338
        tree1.lock_read()
 
339
        tree2.lock_read()
 
340
        self.assertEqual(
 
341
            [self.added(tree2, 'a-id')],
 
342
            self.do_iter_changes(tree1, tree2, specific_file_ids=['a-id']))
 
343
        tree1.unlock()
 
344
        tree2.unlock()
 
345
 
 
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)
 
352
        tree1.lock_read()
 
353
        tree2.lock_read()
 
354
        self.assertEqual(
 
355
            [self.deleted(tree1, 'a-id')],
 
356
            self.do_iter_changes(tree1, tree2, specific_file_ids=['a-id']))
 
357
        tree1.unlock()
 
358
        tree2.unlock()
303
359
 
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', 
317
 
                                                                    'c-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')]
 
369
        tree1.unlock()
 
370
        tree2.unlock()
 
371
        self.assertEqual(expected_result,
 
372
            self.do_iter_changes(tree1, tree2, specific_file_ids=['a-id', 'c-id']))
320
373
 
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)
 
380
        tree1.lock_read()
 
381
        tree2.lock_read()
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))
333
 
        tree1.lock_read()
334
 
        self.addCleanup(tree1.unlock)
335
 
        tree2.lock_read()
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')]
 
392
        tree1.unlock()
 
393
        tree2.unlock()
 
394
        self.assertEqual(
 
395
            expected_results,
 
396
            self.do_iter_changes(tree1, tree2))
341
397
 
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
348
 
        tree1.lock_read()
349
 
        self.addCleanup(tree1.unlock)
350
 
        tree2.lock_read()
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))
356
409
 
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)
362
 
        tree1.lock_read()
363
 
        self.addCleanup(tree1.unlock)
364
 
        tree2.lock_read()
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'),
 
418
                          (False, True))],
 
419
                         self.do_iter_changes(tree1, tree2))
369
420
 
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
376
 
        tree1.lock_read()
377
 
        self.addCleanup(tree1.unlock)
378
 
        tree2.lock_read()
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)))
 
430
                          (False, False))],
 
431
                         self.do_iter_changes(tree1, tree2))
383
432
 
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
390
 
        tree1.lock_read()
391
 
        self.addCleanup(tree1.unlock)
392
 
        tree2.lock_read()
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)))
 
442
                           (False, False))],
 
443
                         self.do_iter_changes(tree1, tree2))
397
444
 
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
404
 
        tree1.lock_read()
405
 
        self.addCleanup(tree1.unlock)
406
 
        tree2.lock_read()
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'),
 
454
                          (False, True))],
 
455
                         self.do_iter_changes(tree1, tree2))
411
456
 
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()
433
479
                          ('a-id', 'd', True, (True, True),
434
480
                          (root_id, root_id), ('a', 'd'), ('file', 'file'),
435
481
                          (False, False)), unchanged('c-id')],
436
 
                         list(tree2._iter_changes(tree1,
437
 
                                                 include_unchanged=True)))
 
482
                         self.do_iter_changes(tree1, tree2, include_unchanged=True))