~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: Robert Collins
  • Date: 2010-04-08 04:34:03 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5139.
  • Revision ID: robertc@robertcollins.net-20100408043403-56z0d07vdqrx7f3t
Update bugfix for 528114 to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
295
295
        tree_a.commit('commit 2')
296
296
        tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
297
297
        tree_b.rename_one('file_1', 'renamed')
298
 
        merger = _mod_merge.Merger.from_uncommitted(tree_a, tree_b,
299
 
                                                    progress.DummyProgress())
 
298
        merger = _mod_merge.Merger.from_uncommitted(tree_a, tree_b)
300
299
        merger.merge_type = _mod_merge.Merge3Merger
301
300
        merger.do_merge()
302
301
        self.assertEqual(tree_a.get_parent_ids(), [tree_b.last_revision()])
310
309
        tree_a.commit('commit 2')
311
310
        tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
312
311
        tree_b.rename_one('file_1', 'renamed')
313
 
        merger = _mod_merge.Merger.from_uncommitted(tree_a, tree_b,
314
 
                                                    progress.DummyProgress())
 
312
        merger = _mod_merge.Merger.from_uncommitted(tree_a, tree_b)
315
313
        merger.merge_type = _mod_merge.WeaveMerger
316
314
        merger.do_merge()
317
315
        self.assertEqual(tree_a.get_parent_ids(), [tree_b.last_revision()])
318
316
 
319
 
    def test_Merger_defaults_to_DummyProgress(self):
320
 
        branch = self.make_branch('branch')
321
 
        merger = _mod_merge.Merger(branch, pb=None)
322
 
        self.assertIsInstance(merger._pb, progress.DummyProgress)
323
 
 
324
317
    def prepare_cherrypick(self):
325
318
        """Prepare a pair of trees for cherrypicking tests.
326
319
 
347
340
 
348
341
    def test_weave_cherrypick(self):
349
342
        this_tree, other_tree = self.prepare_cherrypick()
350
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
343
        merger = _mod_merge.Merger.from_revision_ids(None,
351
344
            this_tree, 'rev3b', 'rev2b', other_tree.branch)
352
345
        merger.merge_type = _mod_merge.WeaveMerger
353
346
        merger.do_merge()
355
348
 
356
349
    def test_weave_cannot_reverse_cherrypick(self):
357
350
        this_tree, other_tree = self.prepare_cherrypick()
358
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
351
        merger = _mod_merge.Merger.from_revision_ids(None,
359
352
            this_tree, 'rev2b', 'rev3b', other_tree.branch)
360
353
        merger.merge_type = _mod_merge.WeaveMerger
361
354
        self.assertRaises(errors.CannotReverseCherrypick, merger.do_merge)
362
355
 
363
356
    def test_merge3_can_reverse_cherrypick(self):
364
357
        this_tree, other_tree = self.prepare_cherrypick()
365
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
358
        merger = _mod_merge.Merger.from_revision_ids(None,
366
359
            this_tree, 'rev2b', 'rev3b', other_tree.branch)
367
360
        merger.merge_type = _mod_merge.Merge3Merger
368
361
        merger.do_merge()
380
373
        this_tree.lock_write()
381
374
        self.addCleanup(this_tree.unlock)
382
375
 
383
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
376
        merger = _mod_merge.Merger.from_revision_ids(None,
384
377
            this_tree, 'rev3b', 'rev2b', other_tree.branch)
385
378
        merger.merge_type = _mod_merge.Merge3Merger
386
379
        merger.do_merge()
399
392
        other_tree.commit('rev2', rev_id='rev2b')
400
393
        this_tree.lock_write()
401
394
        self.addCleanup(this_tree.unlock)
402
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress,
 
395
        merger = _mod_merge.Merger.from_revision_ids(None,
403
396
            this_tree, 'rev2b', other_branch=other_tree.branch)
404
397
        merger.merge_type = _mod_merge.Merge3Merger
405
398
        tree_merger = merger.make_merger()
419
412
        other_tree.commit('rev2', rev_id='rev2b')
420
413
        this_tree.lock_write()
421
414
        self.addCleanup(this_tree.unlock)
422
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
415
        merger = _mod_merge.Merger.from_revision_ids(None,
423
416
            this_tree, 'rev2b', other_branch=other_tree.branch)
424
417
        merger.merge_type = _mod_merge.Merge3Merger
425
418
        tree_merger = merger.make_merger()
449
442
        other_tree.commit('rev2', rev_id='rev2b')
450
443
        this_tree.lock_write()
451
444
        self.addCleanup(this_tree.unlock)
452
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
445
        merger = _mod_merge.Merger.from_revision_ids(None,
453
446
            this_tree, 'rev2b', other_branch=other_tree.branch)
454
447
        merger.merge_type = _mod_merge.Merge3Merger
455
448
        tree_merger = merger.make_merger()
1205
1198
        mem_tree = memorytree.MemoryTree.create_on_branch(builder.get_branch())
1206
1199
        mem_tree.lock_write()
1207
1200
        self.addCleanup(mem_tree.unlock)
1208
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
1201
        merger = _mod_merge.Merger.from_revision_ids(None,
1209
1202
            mem_tree, other_revision_id)
1210
1203
        merger.set_interesting_files(interesting_files)
1211
1204
        # It seems there is no matching function for set_interesting_ids
1985
1978
 
1986
1979
    def do_merge(self, builder, other_revision_id):
1987
1980
        wt = self.get_wt_from_builder(builder)
1988
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
1981
        merger = _mod_merge.Merger.from_revision_ids(None,
1989
1982
            wt, other_revision_id)
1990
1983
        merger.merge_type = _mod_merge.Merge3Merger
1991
1984
        return wt, merger.do_merge()
2251
2244
        wt.commit('D merges B & C', rev_id='D-id')
2252
2245
        self.assertEqual('barry', wt.id2path('foo-id'))
2253
2246
        # Check the output of the Merger object directly
2254
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
2247
        merger = _mod_merge.Merger.from_revision_ids(None,
2255
2248
            wt, 'F-id')
2256
2249
        merger.merge_type = _mod_merge.Merge3Merger
2257
2250
        merge_obj = merger.make_merger()
2307
2300
        wt.commit('F foo => bing', rev_id='F-id')
2308
2301
 
2309
2302
        # Check the output of the Merger object directly
2310
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
2303
        merger = _mod_merge.Merger.from_revision_ids(None,
2311
2304
            wt, 'E-id')
2312
2305
        merger.merge_type = _mod_merge.Merge3Merger
2313
2306
        merge_obj = merger.make_merger()
2358
2351
        list(wt.iter_changes(wt.basis_tree()))
2359
2352
        wt.commit('D merges B & C, makes it a file', rev_id='D-id')
2360
2353
 
2361
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
2354
        merger = _mod_merge.Merger.from_revision_ids(None,
2362
2355
            wt, 'E-id')
2363
2356
        merger.merge_type = _mod_merge.Merge3Merger
2364
2357
        merge_obj = merger.make_merger()
2573
2566
        wt.branch.set_last_revision_info(2, 'B-id')
2574
2567
        wt.commit('D', rev_id='D-id', recursive=None)
2575
2568
 
2576
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
2569
        merger = _mod_merge.Merger.from_revision_ids(None,
2577
2570
            wt, 'E-id')
2578
2571
        merger.merge_type = _mod_merge.Merge3Merger
2579
2572
        merge_obj = merger.make_merger()
2610
2603
        wt.branch.set_last_revision_info(2, 'B-id')
2611
2604
        wt.commit('D', rev_id='D-id', recursive=None)
2612
2605
 
2613
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
2606
        merger = _mod_merge.Merger.from_revision_ids(None,
2614
2607
            wt, 'E-id')
2615
2608
        merger.merge_type = _mod_merge.Merge3Merger
2616
2609
        merge_obj = merger.make_merger()
2650
2643
        wt.branch.set_last_revision_info(2, 'B-id')
2651
2644
        wt.commit('D', rev_id='D-id', recursive=None)
2652
2645
 
2653
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
2646
        merger = _mod_merge.Merger.from_revision_ids(None,
2654
2647
            wt, 'E-id')
2655
2648
        merger.merge_type = _mod_merge.Merge3Merger
2656
2649
        merge_obj = merger.make_merger()
2695
2688
        wt.branch.set_last_revision_info(2, 'B-id')
2696
2689
        wt.commit('D', rev_id='D-id', recursive=None)
2697
2690
 
2698
 
        merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
 
2691
        merger = _mod_merge.Merger.from_revision_ids(None,
2699
2692
            wt, 'E-id')
2700
2693
        merger.merge_type = _mod_merge.Merge3Merger
2701
2694
        merge_obj = merger.make_merger()