~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-09 17:04:46 UTC
  • mfrom: (6055.1.3 822571-bzr-home-unicode)
  • Revision ID: pqm@pqm.ubuntu.com-20110809170446-f1wc1a8fhgnxi4cn
(vila) Decode BZR_HOME with fs encoding to allow unicode homes. (Vincent
 Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    urlutils,
35
35
    workingtree,
36
36
    )
37
 
from bzrlib.tests import script
 
37
from bzrlib.tests import (
 
38
    scenarios,
 
39
    script,
 
40
    )
 
41
 
 
42
 
 
43
load_tests = scenarios.load_tests_apply_scenarios
38
44
 
39
45
 
40
46
class TestMerge(tests.TestCaseWithTransport):
353
359
        self.assertPathExists('file1')
354
360
        self.assertPathDoesNotExist('file2')
355
361
 
 
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
 
356
373
    def pullable_branch(self):
357
374
        tree_a = self.make_branch_and_tree('a')
358
375
        self.build_tree_contents([('a/file', 'bar\n')])
651
668
        this.lock_write()
652
669
        this.unlock()
653
670
 
654
 
    def test_merge_reversed_revision_range(self):
655
 
        tree = self.make_branch_and_tree(".")
656
 
        for f in ("a", "b"):
657
 
            self.build_tree([f])
658
 
            tree.add(f)
659
 
            tree.commit("added "+f)
660
 
        for context in (".", "", "a"):
661
 
            self.run_bzr("merge -r 1..0 " + context)
662
 
            self.assertPathDoesNotExist("a")
663
 
            tree.revert()
664
 
            self.assertPathExists("a")
665
 
 
666
671
    def test_merge_fetches_tags(self):
667
672
        """Tags are updated by merge, and revisions named in those tags are
668
673
        fetched.
684
689
        self.assertEqual('rev-2a', target.tags.lookup_tag('tag-a'))
685
690
        target.repository.get_revision('rev-2a')
686
691
 
 
692
 
 
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
 
687
713
class TestMergeScript(script.TestCaseWithTransportAndScript):
688
714
    def test_merge_empty_branch(self):
689
715
        source = self.make_branch_and_tree('source')