~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_merge.py

(vila) Do not show exception to user on pointless commit error. (Jonathan
 Riddell)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
34
34
    urlutils,
35
35
    workingtree,
36
36
    )
37
 
from bzrlib.tests import (
38
 
    scenarios,
39
 
    script,
40
 
    )
41
 
 
42
 
 
43
 
load_tests = scenarios.load_tests_apply_scenarios
44
37
 
45
38
 
46
39
class TestMerge(tests.TestCaseWithTransport):
359
352
        self.assertPathExists('file1')
360
353
        self.assertPathDoesNotExist('file2')
361
354
 
362
 
    def test_merge_nonexistent_file(self):
363
 
        """It should not be possible to merge changes from a file which
364
 
        does not exist."""
365
 
        tree_a = self.make_branch_and_tree('tree_a')
366
 
        self.build_tree_contents([('tree_a/file', 'bar\n')])
367
 
        tree_a.add(['file'])
368
 
        tree_a.commit('commit 1')
369
 
        os.chdir('tree_a')
370
 
        self.run_bzr_error(('Path\(s\) do not exist: non/existing',),
371
 
                           ['merge', 'non/existing'])
372
 
 
373
355
    def pullable_branch(self):
374
356
        tree_a = self.make_branch_and_tree('a')
375
357
        self.build_tree_contents([('a/file', 'bar\n')])
551
533
 
552
534
    def test_merge_from_submit(self):
553
535
        tree_a = self.make_branch_and_tree('a')
554
 
        tree_a.commit('test')
555
536
        tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
556
537
        tree_c = tree_a.bzrdir.sprout('c').open_workingtree()
557
538
        out, err = self.run_bzr(['merge', '-d', 'c'])
562
543
 
563
544
    def test_remember_sets_submit(self):
564
545
        tree_a = self.make_branch_and_tree('a')
565
 
        tree_a.commit('rev1')
566
546
        tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
567
547
        self.assertIs(tree_b.branch.get_submit_branch(), None)
568
548
 
577
557
 
578
558
    def test_no_remember_dont_set_submit(self):
579
559
        tree_a = self.make_branch_and_tree('a')
580
 
        self.build_tree_contents([('a/file', "a\n")])
581
 
        tree_a.add('file')
582
 
        tree_a.commit('rev1')
583
560
        tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
584
561
        self.assertIs(tree_b.branch.get_submit_branch(), None)
585
562
 
661
638
 
662
639
    def test_merge_interactive_unlocks_branch(self):
663
640
        this = self.make_branch_and_tree('this')
664
 
        this.commit('empty commit')
665
 
        other = this.bzrdir.sprout('other').open_workingtree()
666
 
        other.commit('empty commit 2')
 
641
        other = self.make_branch_and_tree('other')
 
642
        other.commit('empty commit')
667
643
        self.run_bzr('merge -i -d this other')
668
644
        this.lock_write()
669
645
        this.unlock()
670
646
 
 
647
    def test_merge_reversed_revision_range(self):
 
648
        tree = self.make_branch_and_tree(".")
 
649
        for f in ("a", "b"):
 
650
            self.build_tree([f])
 
651
            tree.add(f)
 
652
            tree.commit("added "+f)
 
653
        for context in (".", "", "a"):
 
654
            self.run_bzr("merge -r 1..0 " + context)
 
655
            self.assertPathDoesNotExist("a")
 
656
            tree.revert()
 
657
            self.assertPathExists("a")
 
658
 
671
659
    def test_merge_fetches_tags(self):
672
660
        """Tags are updated by merge, and revisions named in those tags are
673
661
        fetched.
690
678
        target.repository.get_revision('rev-2a')
691
679
 
692
680
 
693
 
class TestMergeRevisionRange(tests.TestCaseWithTransport):
694
 
 
695
 
    scenarios = (('whole-tree', dict(context='.')),
696
 
                 ('file-only', dict(context='a')))
697
 
 
698
 
    def setUp(self):
699
 
        super(TestMergeRevisionRange, self).setUp()
700
 
        self.tree = self.make_branch_and_tree(".")
701
 
        self.tree.commit('initial commit')
702
 
        for f in ("a", "b"):
703
 
            self.build_tree([f])
704
 
            self.tree.add(f)
705
 
            self.tree.commit("added " + f)
706
 
 
707
 
    def test_merge_reversed_revision_range(self):
708
 
        self.run_bzr("merge -r 2..1 " + self.context)
709
 
        self.assertPathDoesNotExist("a")
710
 
        self.assertPathExists("b")
711
 
 
712
 
 
713
 
class TestMergeScript(script.TestCaseWithTransportAndScript):
714
 
    def test_merge_empty_branch(self):
715
 
        source = self.make_branch_and_tree('source')
716
 
        self.build_tree(['source/a'])
717
 
        source.add('a')
718
 
        source.commit('Added a', rev_id='rev1')
719
 
        target = self.make_branch_and_tree('target')
720
 
        self.run_script("""\
721
 
$ bzr merge -d target source
722
 
2>bzr: ERROR: Merging into empty branches not currently supported, https://bugs.launchpad.net/bzr/+bug/308562
723
 
""")
724
 
 
725
681
class TestMergeForce(tests.TestCaseWithTransport):
726
682
 
727
683
    def setUp(self):