/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Olaf Conradi
  • Date: 2006-04-02 02:35:12 UTC
  • mto: (1661.1.1 bzr.mbp.remember)
  • mto: This revision was merged to the branch mainline in revision 1663.
  • Revision ID: olaf@conradi.org-20060402023512-18754201284048f0
Add test case for resetting parent in branch_implementations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005 by Canonical Ltd
 
2
# -*- coding: utf-8 -*-
 
3
 
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; either version 2 of the License, or
 
7
# (at your option) any later version.
 
8
 
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
 
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 
 
18
 
 
19
"""Black-box tests for bzr merge.
 
20
"""
 
21
 
 
22
import os
 
23
 
 
24
from bzrlib.branch import Branch
 
25
from bzrlib.tests.blackbox import ExternalBase
 
26
from bzrlib.osutils import abspath
 
27
 
 
28
 
 
29
class TestMerge(ExternalBase):
 
30
 
 
31
    def example_branch(test):
 
32
        test.runbzr('init')
 
33
        file('hello', 'wt').write('foo')
 
34
        test.runbzr('add hello')
 
35
        test.runbzr('commit -m setup hello')
 
36
        file('goodbye', 'wt').write('baz')
 
37
        test.runbzr('add goodbye')
 
38
        test.runbzr('commit -m setup goodbye')
 
39
 
 
40
    def test_merge_remember(self):
 
41
        """Merge changes from one branch to another and test parent location."""
 
42
        os.mkdir('a')
 
43
        os.chdir('a')
 
44
 
 
45
        self.example_branch()
 
46
        self.runbzr('branch . ../b')
 
47
        self.runbzr('branch . ../c')
 
48
        file('bottles', 'wt').write('99 bottles of beer on the wall')
 
49
        self.runbzr('add bottles')
 
50
        self.runbzr('commit -m 99_bottles')
 
51
        os.chdir('../b')
 
52
        b = Branch.open('')
 
53
        parent = b.get_parent()
 
54
        # reset parent
 
55
        b.set_parent(None)
 
56
        self.assertEqual(None, b.get_parent())
 
57
        # test merge for failure without parent set
 
58
        out = self.runbzr('merge', retcode=3)
 
59
        self.assertEquals(out,
 
60
                ('','bzr: ERROR: No merge branch known or specified.\n'))
 
61
        # test implicit --remember when no parent set, this merge conflicts
 
62
        file('bottles', 'wt').write('98 bottles of beer on the wall')
 
63
        self.runbzr('add bottles')
 
64
        out = self.runbzr('merge ../a', retcode=3)
 
65
        self.assertEquals(out,
 
66
                ('','bzr: ERROR: Working tree has uncommitted changes.\n'))
 
67
        self.assertEquals(abspath(b.get_parent()), abspath(parent))
 
68
        # test implicit --remember after resolving conflict
 
69
        self.runbzr('revert')
 
70
        os.unlink('bottles')
 
71
        self.runbzr('merge')
 
72
        self.assertEquals(abspath(b.get_parent()), abspath(parent))
 
73
        self.runbzr('commit -m merge_a')
 
74
        # test explicit --remember
 
75
        self.runbzr('merge ../c --remember')
 
76
        self.assertEquals(abspath(b.get_parent()), abspath('../c'))
 
77
        self.runbzr('commit -m merge_c --unchanged')